Wednesday, January 30, 2008

Adding dynamic text to RDLC in Code Behind + VB.net

Sometimes you want to display text in report viewer but you need to be able to populate the value from the code behind.

1. Create a parameter in the Report (.rdlc file)



2. Add a texbox to the report – right click properties.
Click on the first tab “General” click the “formula” button.



3. Add code to code behind where you have added the RDLC to the page.



Dim p As New ReportParameter("getDate", DateTime.Now())
Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {p})
Me.ReportViewer1.LocalReport.Refresh()

No comments: