C# 如何将参数传递到asp.net web应用程序中具有对象数据源的本地报表?
我想将参数传递给具有对象数据源的本地报表从cmethod获取需要参数的数据列表,我如何才能做到这一点C# 如何将参数传递到asp.net web应用程序中具有对象数据源的本地报表?,c#,asp.net,reporting-services,C#,Asp.net,Reporting Services,我想将参数传递给具有对象数据源的本地报表从cmethod获取需要参数的数据列表,我如何才能做到这一点 #region Parameterized Report ReportViewer1.ProcessingMode = ProcessingMode.Local; string FolderPath = Server.MapPath("~/LocalReports"); string ReportName = "Pa
#region Parameterized Report
ReportViewer1.ProcessingMode = ProcessingMode.Local;
string FolderPath = Server.MapPath("~/LocalReports");
string ReportName = "ParameterizedReportWizard.rdlc";
string DataSetName = "DataSet1Parameter";
string SelectedMethod = "GetSomeEmployees";
string Parameter = "ID";
ReportViewer1.LocalReport.ReportPath = Path.Combine(FolderPath, ReportName);
ObjectDataSource objDataSource = new ObjectDataSource() { ID = DataSetName, TypeName = "BussinessLogic.Custom", SelectMethod = SelectedMethod};
ReportParameter p1 = new ReportParameter("ReportParameter1", "1"); //I pass the same parameter name tha exist in report definition and it's value is on 1 as static value for now
this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1});
ReportDataSource datasource = new ReportDataSource(DataSetName, objDataSource);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
#endregion
本地报表的所有数据访问都应在将其绑定到报表之前执行。如果可能,在源位置进行过滤 您需要添加到ObjectDataSource.SelectParameter集合
string DataSetName = "DataSet1Parameter";
string SelectedMethod = "GetSomeEmployees";
string Parameter = "ID";
ObjectDataSource objDataSource = new ObjectDataSource() { ID = DataSetName, TypeName = "BussinessLogic.Custom", SelectMethod = SelectedMethod};
objDataSource.SelectParameters.Add(new Parameter("id"));
然后订阅ObjectDataSource。选择事件以设置参数
protected void objDataSource_Selecting
(object sender, ObjectDataSourceSelectingEventArgs e)
{
e.InputParameters["id"] = "1";
}
这里有一个相关的帖子。但我的情况是,返回我的对象列表的方法=有参数,我怎么做,plz帮助?在报告中显示参数怎么样?我应该手动添加参数控件,还是在报表服务器的情况下自动生成?您的参数必须在报表定义中才能在报表中使用,所以请正常添加。好的,实际上我是在报表定义中这样做的。但是SetParameters还是帮不了我?!你能更新你的帖子来显示你是如何设置你的参数的吗?我已经更新了它,我在运行后得到了这个错误:在报告处理过程中发生了一个错误。ObjectDataSource“DataSet1Parameter”找不到没有参数的非泛型方法“GetSomeEmployees”。