user2379049
user2379049

Reputation:

ReportViewer Multiple Report Parameters

Is it possible to include multiple report parameters in a single line? if i have like 10 parameters, i don't want to create an "add" keyword 10 times ...

LocalReport.SetParameters("NewParameter1", "First one")

Having to repeat that would seem redundant

Upvotes: 2

Views: 5019

Answers (2)

Harry.wong
Harry.wong

Reputation: 12

    Dim param As ReportParameter() = New ReportParameter(2) {}

    For i As Int16 = 0 To 2
        param(i) = New ReportParameter("item" & i + 1, tb_PartDesc.Text)
    Next

    viewer.LocalReport.SetParameters(param)

add item1 item2 item3 in reportviewer parameter enter image description here

Upvotes: 0

Alex
Alex

Reputation: 4938

Just store the parameters in an array ... For example:

Dim rpTitle = New ReportParameter("rpTitle", "Your title")
Dim rpDate = New ReportParameter("rpDate", Date.Now())
Dim HeaderParams As ReportParameter() = {rpTitle, rpDate}

Now you have an array which contains two report parameters ... (it can include much more).

Then you just need to loop through the HeaderParams array like so:

For Each param As ReportParameter In HeaderParams
    LocalReport.SetParameters(param)
Next

That way you don't need to SetParameters more than once in your code... The loop will do it.

Upvotes: 3

Related Questions