RDLC动态图像添加到报告 [英] RDLC dynamically add images to report

查看:174
本文介绍了RDLC动态图像添加到报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在远程服务器上的图像列表,我需要展示一些这些图像在现有报告。我试图通过删除的图像控制的RDLC,它适用于单一的形象。

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 image.

但我需要显示多个图像,它没有固定的数量。

But i need to show more than one image, which has no fixed count.

我在下面提及的职位,但没有一个是明确的:

I referred below posts, but none are clear:

C# - 添加列表图片报道观众

<一个href=\"http://stackoverflow.com/questions/2036570/insert-unknown-number-of-images-to-the-report-at-runtime-using-reportviewer\">Insert未知号码使用图片来报告在运行时的ReportViewer

<一个href=\"http://www.c-sharpcorner.com/blogs/6194/display-image-in-rdlc-report-microsoft-report-viewer.aspx%27\" rel=\"nofollow\">http://www.c-sharpcorner.com/blogs/6194/display-image-in-rdlc-report-microsoft-report-viewer.aspx%27

我知道有可能重复这个要求,请指导我,如果左右。

I know there might be possible duplicates for this request, please guide me if so.

推荐答案

我开始通过添加表到现有的报告,如在上面提到的后,除去不必要的列,则在增加了一个图像向左出细胞RDLC设计。在图像属性设置源为外部

I started by adding a table to the existing reports, as in above mentioned post, removed the unnecessary columns, then added an image to the left out cell in the rdlc design. In the image property set the source to "External"

现在打开XML视图的RDLC,有找到数据标签,添加一个新的数据与图像的新表

Now open the rdlc in xml view, there find the dataset tag, add a new dataset for the new table with images

<DataSet Name="DataSet1">
  <Fields>
    <Field Name="filepath">
      <DataField>track_file_id_pk</DataField>
      <rd:TypeName>System.string</rd:TypeName>
    </Field>
    </Field>
  </Fields>
  <Query>
    <DataSourceName>xxxt</DataSourceName>
    <CommandText>/* Local Query */</CommandText>
  </Query>
  <rd:DataSetInfo>
    <rd:DataSetName>xxx</rd:DataSetName>
    ...
  </rd:DataSetInfo>
</DataSet>

现在添加图像列表数据到新表如下所示

Now adding the images list dataset to the new table as shown below

<Tablix Name="Tablix2">
    ....
    </TablixRowHierarchy>
    <DataSetName>ImgDataSet</DataSetName>

返回到设计视图RDLC的,去图像属性,设置了使用此图片字段

Go back to design view of rdlc, go to image properties, set the "use this image" field

在code背后创建数据表有一列文件路径,用图片文件路径添加行
然后添加数据源来报告现有数据源的下面。

In code behind create Datatable with one column "filepath", add rows with images filepath then add datasource to report below the existing datasource.

DataTable dtable = new DataTable();
DataColumn dcol = new DataColumn("filepath");
dtable.Columns.Add(dcol);

DataRow drow = dtable.NewRow();
string pat = new Uri(Server.MapPath("~/Content/DSC_019.jpg")).AbsoluteUri;
drow["track_file_uuidName"] = pat;
dtable.Rows.Add(drow);
...

ReportViewer1.LocalReport.EnableExternalImages = true;

...
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("rptDataSet", objCommonreport.ReportTable));
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dtable));

这篇关于RDLC动态图像添加到报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆