views:

409

answers:

1

Chart on reportviewer does not load unless i click view report button when combolist parameters are passed.

All the selected parameters are passed correctly and report loads only after clicking 'view report' button on the report viewer. I have this report viewer on an ASP.NET page and my parameters are passed using session variables created from another ASP.NET page which has my parameters form from where the user enters and selects input parameters.

I have dates(date picker) and company names (multiselect combo list with check boxes) as input parameters.

Report works absolutely fine unless the report parameters come from multiselect combo list.

Here is my code I used for establishing report parameters as session variables.

Session("labname") = Nothing
    Session("fractionid") = FractionDropDownList.SelectedValue
    For intloopindex As Integer = 0 To LabNamesCheckBoxList.Items.Count - 1
        If LabNamesCheckBoxList.Items(intloopindex).Selected Then
            Session("labname") &= LabNamesCheckBoxList.Items(intloopindex).Text & ControlChars.CrLf
        End If
    Next
    Session("sdate") = sdate.text
    Session("edate") = edate.text

Here is my code for passing these session variables as parameters to reportviewer control.

If Not IsPostBack Then

        Dim fractionparam As String
        Dim sdateparam As String
        Dim edateparam As String
        Dim regionparam As String
        Dim labnameparam As String

        regionparam = Session("regionid")
        fractionparam = Session("fractionid")
        labnameparam = Session("labname")
        sdateparam = Session("sdate")
        edateparam = Session("edate")


        Dim rp(3) As Microsoft.Reporting.WebForms.ReportParameter

        'rp(0) = New Microsoft.Reporting.WebForms.ReportParameter("regionid", regionparam)
        rp(0) = New Microsoft.Reporting.WebForms.ReportParameter("fractionid", fractionparam)
        rp(1) = New Microsoft.Reporting.WebForms.ReportParameter("labname", labnameparam)
        rp(2) = New Microsoft.Reporting.WebForms.ReportParameter("sdate", sdateparam)
        rp(3) = New Microsoft.Reporting.WebForms.ReportParameter("edate", edateparam)

        Me.ReportViewer1.ServerReport.SetParameters(rp)

    End If
A: 

I finally got the solution.

I was doing one major mistake with my old code. With the multivalue parameter, I was trying to send all the selected values from combo box list as one string.

But I should have used a string array to store the multivalue parameters and send them using the session variable.

Included the code below.

dim count as integer
For intloopindex As Integer = 0 To LabNamesCheckBoxList.Items.Count - 1
        If LabNamesCheckBoxList.Items(intloopindex).Selected Then
          count=count+1
        End If    
dim labnames(count) as array

dim j as integer
j=0

for i as integer=0 to labnamescheckboxlist.items.count-1
labnames(j)=labnamescheckboxlist.item(i).text
j=j+1
next

    Session("labname") = Nothing
    Session("labname")=labnames

    Session("fractionid") = FractionDropDownList.SelectedValue
    Session("sdate") = sdate.text
    Session("edate") = edate.text

In the target page, read pass all the session variables as parameters as shown the code earlier post.

SQL Baba