开发者

Displaying single-instance business object data on SSRS

开发者 https://www.devze.com 2022-12-14 04:12 出处:网络
I have a SQL Server Reporting Services local (i.e. RDLC) report displayed in a ReportViewer, with two subreports. I am using business objects to populate the datasets. What is the best way to populate

I have a SQL Server Reporting Services local (i.e. RDLC) report displayed in a ReportViewer, with two subreports. I am using business objects to populate the datasets. What is the best way to populate single-instance data on my report, e.g. a dynamic title, or a text box that lists a calculated value, not based on the report data?

I am currently displaying data using the following style:

public class MyRecordList
{
   string Name { get; set; }
   List<开发者_开发知识库MyRecord> Records { get; set;}
}

public MyRecord
{
   string Description { get; set;}
   string Value { get; set;}
}

I set the datasource to the Records in an instance of MyRecordsList, and they print out find in a table. But adding a textbox and and referring to Name displays nothing. I also tried turning Name into a List, and referring to the first in the list, using:

=First(Fields!Name.Value, "Report1_MyRecordList")

but still nothing is printed on the report.


This would be easiest to do with a parameter to the report. Load the report in the report designer and select the Report menu and go to Parameters. Add a string parameter and give it a good name. You can then refer to the parameter in the body of the report with =Parameters.nameOfParameter.Value

Then add this code before loading the report:

myReportViewer.LocalReport.SetParameters(new ReportParameter[] { new ReportParameter("nameOfParameter", "parameter's value") });

0

精彩评论

暂无评论...
验证码 换一张
取 消