Report Parameters for RDLC and ReportViewer in VB.NET

2.6k Views Asked by At

I'm currently learning on how to do a filtering of reports of ReportViewer, I've done searching via internet and found some useful tips, here is what i did:

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
    Dim USER As New ReportParameter("user", txtuser.Text)
    Try
        Me.DataTableTableAdapter.Fill(Me.DataSet3.DataTable, DateTimePicker1.Value.Date, DateTimePicker2.Value.Date)
        ReportViewer1.LocalReport.SetParameters(New ReportParameter() {USER})
        ReportViewer1.RefreshReport()
    Catch ex As Exception
        MessageBox.Show(ex.ToString)
    End Try
End Sub

and on the form load I added this code:

Private Sub AuditReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.DataTableTableAdapter.Fill(Me.DataSet3.DataTable,DateTimePicker1.Value.Date, DateTimePicker2.Value.Date)
ReportViewer1.RefreshReport()
end sub

The problem is when the ReportViewer loaded it does not show the data(contents) but the blanks like this:

enter image description here

and data only shows when I type on search user textbox like here:

enter image description here

Notice that when I type "label5" on textbox the data shows all label5, and that's my target, but what I also want is when the ReportViewer loaded, it should show all the data for reports not blanks, and if the textbox is blank it should show all data reports.

This is the paramater for search username:

enter image description here

Filtering report through date works just fine and it loads the data reports from the start but the problem happens when I tried to add report parameter for username filtering.

0

There are 0 best solutions below