Search code examples
rdlcdynamic-rdlc-generation

How to bind data coming from dataset to header in rdlc reports?


Expected: I need to get values coming from the dataset to put them in the header.

I've done some work around: -Create textboxs in the body area, populate them with the correct values coming from dataset. Get the values from the Header like this: ReportItems!txtFromBody.Value

No luck! The header is filled out with the correct information in the last page only.

I thought maybe I can use parameters, not sure at this point. Need some help!!


Solution

  • Yes you can use parameter for header. enter image description here

    Now add parameter

    // Add Parameter 
                List<ReportParameter> parameters = new List<ReportParameter>();
                parameters.Add(new ReportParameter("AccountName", accountName));
                parameters.Add(new ReportParameter("AccountCode", "Account Code: " + accountCode));
                parameters.Add(new ReportParameter("UnitName", unitName.ToUpper()));
                parameters.Add(new ReportParameter("UnitAddress", unitAddress.ToUpper()));
                parameters.Add(new ReportParameter("Title", "Schedule"));
                parameters.Add(new ReportParameter("Date", dateVal));
                ReportViewer1.LocalReport.SetParameters(parameters);
                ReportViewer1.ShowParameterPrompts = false;
                ReportViewer1.ShowPromptAreaButton = false;
                ReportViewer1.LocalReport.Refresh();