.NET RDLC and multiple parameters not working
-
06-07-2019 - |
Question
I have a report that takes two parameters from a couple of text boxes that always ends up being null when passed to the stored proc. Here is the code. Also I stepped through the code and the passed in parameters have values but between passing in the params to when the proc is executed it becomes null.
protected void btnSearch_Click(object sender, EventArgs e)
{
pnlRecords.Visible = true;
ReportParameter p1 = new ReportParameter("DateStart", ReportDates1.DateStart);
ReportParameter p2 = new ReportParameter("DateEnd", ReportDates1.DateEnd);
this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { p1, p2 });
this.ReportViewer1.LocalReport.Refresh();
}
What do you think?
Solution
I figured it out. Here is what I was missing in the .cs file
ObjectDataSource1.SelectParameters[0].DefaultValue = ReportDates1.DateStart;
ObjectDataSource1.SelectParameters[1].DefaultValue = ReportDates1.DateEnd;
ObjectDataSource1.DataBind();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow