I am working on SSRS report. Here is the cs file code:
new protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String reportTitle = GetValueFromQueryString("ReportTitle");
/* Get Agency name and set it in report parameters */
AgencyBO agencyBO = new AgencyBO();
Agency agency = new Agency();
agency = agencyBO.GetAgencyInformation();
List<ReportParameter> lstParam = new List<ReportParameter>();
lstParam.Add(new ReportParameter("Agency", agency.Name));
/* Declare parameters that are to be sent to Report Helper class */
string orderBy = string.Empty,
startAge = string.Empty,
endAge = string.Empty,
sex = string.Empty,
staffId = string.Empty,
statusId = string.Empty,
ethnicityId = string.Empty,
treatmentProviderId = string.Empty;
ConsumerSummaryReportCriteria consumerSummaryReportCriteria = new ConsumerSummaryReportCriteria();
Dictionary<String, String> lst = consumerSummaryReportCriteria.GetReportParams();
foreach (var pair in lst)
{
/* ---- Set parameters that are to be sent to Report Helper class ---- */
if (pair.Key == "orderBy" && pair.Value != string.Empty)
{
orderBy = pair.Value;
}
if (pair.Key == "startAge" && pair.Value != string.Empty)
{
startAge = pair.Value;
lstParam.Add(new ReportParameter("startAge", pair.Value));
}
if (pair.Key == "endAge" && pair.Value != string.Empty)
{
endAge = pair.Value;
lstParam.Add(new ReportParameter("endAge", pair.Value));
}
if (pair.Key == "gender" && pair.Value != string.Empty)
{
sex = pair.Value;
lstParam.Add(new ReportParameter("gender", pair.Value));
}
if (pair.Key == "staffIds" && pair.Value != string.Empty)
{
staffId = pair.Value;
}
if (pair.Key == "consumerStatusIds" && pair.Value != string.Empty)
{
statusId = pair.Value;
}
if (pair.Key == "ethnicityIds" && pair.Value != string.Empty)
{
ethnicityId = pair.Value;
}
if (pair.Key == "treatmentProviderIds" && pair.Value != string.Empty)
{
treatmentProviderId = pair.Value;
}
/* ---- Set parameters to report parameters list that are to be sent to
* RDLC to show report selection criteria at the end of the report ---- */
if (pair.Key == "staffNames")
{
lstParam.Add(new ReportParameter("staffNames", pair.Value));
}
if (pair.Key == "consumerStatusNames")
{
lstParam.Add(new ReportParameter("consumerStatusNames", pair.Value));
}
if (pair.Key == "treatmentProviderNames")
{
lstParam.Add(new ReportParameter("treatmentProviderNames", pair.Value));
}
if (pair.Key == "ethnicityNames")
{
lstParam.Add(new ReportParameter("ethnicityNames", pair.Value));
}
}
ReportHelper.ApplyReportSetting(ref rptConsumerSummaryReport, reportTitle, orderBy, startAge, endAge, sex, staffId, statusId, ethnicityId, treatmentProviderId);
rptConsumerSummaryReport.LocalReport.SetParameters(lstParam);
rptConsumerSummaryReport.LocalReport.Refresh();
}
}
It was working perfectly but suddenly stopped working.
A blank aspx page opens and report viewer does not open.
Here is the code of aspx file.
<form id="frmConsumerSummaryReport" runat="server">
<div>
<asp:ScriptManager ID="scmReport" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="rptConsumerSummaryReport" runat="server" Height="100%" AsyncRendering="False"
Width="100%" SizeToReportContent="True" Font-Names="Verdana"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Reports\Consumer\ConsumerSummaryReport.rdlc">
</LocalReport>
</rsweb:ReportViewer>
</div>
</form>
I added some new parameters in my report after that it stopped working. No idea why this happened. After removing those parameters, it’s working fine again.
EDIT: It was so because those parameter had null value. When I set their property to Allow “” and null values, it started working.