从RDLC检索参数
本文关键字:参数 检索 RDLC | 更新日期: 2023-09-27 18:01:29
如何从RDLC本地报表中检索报表参数
LocalReport localReport = (LocalReport)e.Report;
ReportParameterInfoCollection ps = new ReportParameterInfoCollection();
ps = localReport.GetParameters();
ReportParameter paramV = new ReportParameter();
我想保存一个特定的参数,它的值在"paramV"
在钻取报告中,我使用以下代码获取参数并将其发送到下一个数据源:
LocalReport localReport = (LocalReport)e.Report;
//Get all the parameters passed from the main report to the target report.
//OriginalParametersToDrillthrough actually returns a Generic list of
//type ReportParameter.
IList<ReportParameter> list = localReport.OriginalParametersToDrillthrough;
DataTable DT = new DataTable();
string org = null;
string status = null;
//Parse through each parameters to fetch the values passed along with them.
foreach (ReportParameter param in list)
{
if (param.Name == "org")
org = param.Values[0].ToString();
else if (param.Name == "status")
status = param.Values[0].ToString();
}
// Request the datatable from ADO.NET for example or any source that will need the parameters
var dataSet1 = new DataSets.xx.yy();
if (string.IsNullOrEmpty(org) && string.IsNullOrEmpty(status))
DT = dataSet1.GetAllData();
else
DT = dataSet1.GetDataByOrgStatus(org, status);
localReport.DataSources.Add(new ReportDataSource("DSName", DT));
localReport.Refresh();