ReportViewer from code behind RRS feed

  • Question

  • User939573946 posted


    I have a problem with creating reportviewer dynamically, on my page load even existing code works, but on button click not,any ideas why is this happening?Here is my code:

      Dim Report As New ReportViewer
    Report.ProcessingMode = ProcessingMode.Local
    Report.LocalReport.ReportPath = Server.MapPath("Reports\Report.rdlc")
    Dim DataSet1 As New ReportDataSource
    DataSet1.Name = "DataSet1"
    DataSet1.DataSourceId = "ObjectDataSource1"

    Dim Dataset2 As New ReportDataSource
    Dataset2.Name = "DataSet2"
    Dataset2.DataSourceId = "ObjectDataSource2"

    ObjectDataSource1.SelectParameters("param1").DefaultValue = "value1"
    ObjectDataSource1.SelectParameters("param2").DefaultValue = "value2"
    ObjectDataSource1.SelectParameters("param3").DefaultValue = "value2"
    Thank's for replay

    Friday, November 18, 2011 1:25 AM

All replies

  • Saturday, November 19, 2011 6:40 AM
  • User-830595639 posted

    Hi Marko,

    If your code is working from PageLoad event it should also work with ButtonClick event. Please chec your code in ButtonClick and if its giving you error please explain it that what kind of error you are getting.

    Monday, November 21, 2011 4:32 AM
  • User939573946 posted

    Hi Nishant,

    There is no error on button click event,and the code is same as on page load event. Maybe is something wrong with binding report, because button click shows empty reportviewer...

    Tuesday, November 22, 2011 12:13 AM
  • User-830595639 posted

    Hi Marko,

    Please check your value which are getting passed when you are using the button click event. To do so you can take a text box and call your parameter value and then try to see if the value displaying in your report is working with the query in database directly. Like this you need to find out the problem. Because there is no difference in calling a code from PageLoad and button click.

    I hope this will help you.

    Tuesday, November 22, 2011 4:40 AM