I have list of images in remote server, i need to show some of these images in a existing report. I tried by dropping an image control to the rdlc and it works for single im
I did the following to show a list of images with unknown number of items in a matrix.
First create a dataset with only one field in it, you can whatever you want , i named it "filepath" and name of dataset to be "DataSet5". You can change the name and use it accordingly.
Then you need to add a table, delete unnecessary rows and columns such that you are left with only 1 column and row (1x1) matrix. Insert an image in that column, set its properties now. Image source should be EXTERNAL.
In your aspx.cs file for the report, get the paths of the images from the database, now get absolute paths for these and append "file:///" as reports require a file to be shown. I did like this:
string rel_Path = HttpContext.Current.Server.MapPath("~");
if (_articleOrders.Any())
{
foreach (ArticleOrder order in _articleOrders)
{
if (!string.IsNullOrEmpty(order.ArticleImage))
{
if (File.Exists(rel_Path + "\\" + order.ArticleImage))
{
var AIpath = "file:///" + rel_Path + "\\" + order.ArticleImage;
articleImagesList.Add(AIpath);
}
}
}
CreateDatasetForImages(articleImagesList);
}
Then I added data to dataset like below:
private void CreateDatasetForImages(List articleImagesList)
{
DataTable table = new DataTable();
table.Columns.Add("filepath", typeof(string));
foreach (string articleImage in articleImagesList)
{
DataRow drow = table.NewRow();
string pat = articleImage;
drow["filepath"] = pat;
table.Rows.Add(drow);
}
FlowerBookingReportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet5", table));
}
Now again go to image properties and set "Use This Image" to [filepath] as it the name of the column in our dataset that is holding the path of the image. Hope it works for someone!