我在报告中有一个子报告,我将一个参数传递给子报告tutorUsername
。
创建报告时我的代码是:
reportViewer1.LocalReport.ReportPath = (reportPath + "TestReport.rdlc");
reportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(prcProcessSubReport);
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("test_DataSet", report));
ReportParameter[] tmpParameters = new ReportParameter[1];
tmpParameters[0] = new ReportParameter("serverNames", serverNamesList, false);
reportViewer1.LocalReport.SetParameters(tmpParameters);
并且:
private void prcProcessSubReport(object sender, SubreportProcessingEventArgs e)
{
try
{
string tutorUserName = e.Parameters["tutorusername"].Values[0].ToString();
ReportDataSource rdsTradeDetails = new ReportDataSource("Test_DataSet", report);
e.DataSources.Add(rdsTradeDetails);
//Code End
}
catch (Exception eX)
{
}
}
现在的问题是我确实得到了参数valye但它的(Fields!Tutor_Username.Value, \"TEST_DataSet\")
。我假设这样我将获得每个的教师用户名,我将使用参数创建/过滤数据表并相应地添加。有帮助吗?我做错了是否有其他方法来获取参数值?
答案 0 :(得分:0)
IT很简单,必须这样做:
string tutorUserName = (e.Parameters["tutorusername"].Values.First()).ToString();
ReportDataSource rdsTradeDetails = new ReportDataSource("Test_DataSet", report);
e.DataSources.Add(rdsTradeDetails);