set report parameters for ReportViewer control in 2005

Discussion in 'ASP .Net' started by tfsmag, Feb 24, 2006.

  1. tfsmag

    tfsmag Guest

    So I used the code directly from the msdn site at
    http://msdn2.microsoft.com/en-us/li...ting.webforms.serverreport.setparameters.aspx

    here is my exact code

    --code--
    Private Sub SetReportParameters()
    Dim p As New ReportParameter("userid",
    Security.GetUserID().ToString())
    ReportViewer1.ServerReport.SetParameters(p)
    End Sub
    --code--

    When I use that Sub it returns this error...

    --error--
    Unable to cast object of type
    'Microsoft.Reporting.WebForms.ReportParameter' to type
    'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WebForms.ReportParameter]'.

    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: System.InvalidCastException: Unable to cast object
    of type 'Microsoft.Reporting.WebForms.ReportParameter' to type
    'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WebForms.ReportParameter]'.
    --error--

    Any help is greatly appreciated.
    tfsmag, Feb 24, 2006
    #1
    1. Advertising

  2. tfsmag

    tfsmag Guest

    never mind, i found my answer, here is the code i used.

    Private Sub SetReportParameters()
    Dim userid As New ReportParameter("userid",
    Security.GetUserID().ToString())
    Dim p() As ReportParameter = {userid}
    ReportViewer1.ServerReport.SetParameters(p)
    End Sub
    tfsmag, Feb 24, 2006
    #2
    1. Advertising

  3. tfsmag

    sturner333

    Joined:
    Dec 15, 2008
    Messages:
    1
    This last post worked for me for a stand-alone report and form. Does anyone know how to aplly to a form with multiple sub-reports?
    Thanks
    sturner333, Dec 15, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Dvali
    Replies:
    0
    Views:
    674
    David Dvali
    Dec 23, 2005
  2. Larry Bud
    Replies:
    1
    Views:
    726
    Larry Bud
    Nov 21, 2007
  3. Sheena Abraham
    Replies:
    0
    Views:
    1,767
    Sheena Abraham
    Nov 29, 2007
  4. Sharon
    Replies:
    1
    Views:
    1,243
    Alexey Smirnov
    Nov 6, 2009
  5. David
    Replies:
    3
    Views:
    1,141
    Patrice
    Dec 1, 2009
Loading...

Share This Page