In 1 to 1 related product and picture tables, the relationship id is pictureid. On the side with multiple pictures, picture paths are hidden in the picture variable. It looks like /picturedirectory/h.jpg. The pictures are physically present in the picturedirectory folder. I want to extract the picture or pictures from the id of a product with microsoft.reportviewer. It means printing from the picture table. The pictures are in the pictures folder. I could not find asp net dot net and asp net mvc examples regarding this. Best regards
Loading


Naimish MakwanaRank #324 · 7.7K reputationPosted Apr 1, 2024, 12:26 AM EDT
If you have the image paths stored in your database and the images are physically present in a directory, you can display these images in your ReportViewer control by setting the image source to “External” and providing the image path. Here’s how you can do it:
this.ReportViewer1.LocalReport.EnableExternalImages = true;Please replace the placeholders with your actual data.
Thanks
Omer Ayna66 reputationPosted Apr 1, 2024, 7:28 AM EDT
I am looking for a code to list the expression stored in the imagepath variable in the image table from the physical image file folder according to the imageid relationship from the product id to the image table linked to it in multiple related tables.
Jayraj ChhayaRank #304 · 8.2K reputationPosted Apr 1, 2024, 8:14 AM EDT
To extract pictures from the picture table based on the product ID using Microsoft ReportViewer in a Dot Net MVC application, you can follow these steps:
// Assume you have the product ID stored in productId variable int productId = 1; // Retrieve picture path(s) from the database based on the productId var picturePaths = db.Pictures.Where(p => p.ProductId == productId).Select(p => p.Path).ToList(); // Pass the picturePaths to the ReportViewer control ReportDataSource reportDataSource = new ReportDataSource("PicturesDataSet", picturePaths); ReportViewer1.LocalReport.DataSources.Add(reportDataSource); ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/ProductPicturesReport.rdlc"); ReportViewer1.LocalReport.Refresh();Ensure that you have a report (ProductPicturesReport.rdlc) set up with an image control bound to the picture path(s) dataset.