问题
I am trying to create report for TOP (according to user provide say 10,100,200..) products. I am 90% success with it. Now, I am finding difficulties to show this numbers to Report header. So, my report header is saying Top Products, now I want to make this dynamic, saying Top 100 Products, Top 200 Products.
I AM USING VS 2008.
For this, I created parameter in ReportViewer. I tried this code in Page_Load event ;
protected void Page_Load(object sender, EventArgs e)
{
ReportDataSource rds = new ReportDataSource("SP_GetProductsbySales_DataSet");
//ReportViewer1.ServerReport.ReportPath = "Report1.rdlc";
ReportViewer1.LocalReport.ReportPath = "Report1.rdlc";
ReportParameter[] param = new ReportParameter[1];
param[0] = new ReportParameter("top", "100");
ReportViewer1.ServerReport.SetParameters(param);
ReportViewer1.ServerReport.Refresh();
}
but getting error saying : The source of the report definition has not been specified.
How can I accomplish this one? I tried to google as well as watched some videos, but still I am not getting any idea.
Thanks.
回答1:
Please set data source
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rds);
回答2:
You can set an expression in your report to show the value.
The expression would be as follows:
="Top " & Parameters!top.Value & " Products"
来源:https://stackoverflow.com/questions/15060213/how-can-i-pass-parameter-to-reportviewer