Dynamic dataset for rdlc?

Last post 05-13-2008 12:30 AM by Nai-Dong Jin - MSFT. 1 replies.

Sort Posts:

  • Dynamic dataset for rdlc?

    05-09-2008, 6:13 PM
    • Loading...
    • DesertDude
    • Joined on 06-01-2005, 10:56 PM
    • Tucson, Arizona, USA
    • Posts 294

    I've seen code that sets up a reportviewer dynamically, like this:

    Dim dtReport As New DataTable = GetDataTable("Rpt1")

    LocalReport.ReportPath = "Rpt1.rdlc"

    Dim rdsReport As New ReportDataSource
    rdsReport.Name = "Rpt1Data"
    rdsReport.Value = dtReport
    ReportViewer1.LocalReport.DataSources.Add(rdsReport)

    ReportViewer1.LocalReport.Refresh()

    I'd like to be able to use this approach, but VS2005 complains if my rdlc does not have a DataSet. Is there a way to set up the dataset in the rdlc so that I don't have to actually wire it up to data, since I need to do that dynamically in code?

    Thank you.

  • Re: Dynamic dataset for rdlc?

    05-13-2008, 12:30 AM
    Answer

    Hi,

     

    If you are using the ReportViewer control in local mode, the dataset has to be retrieved through your application code. Then the dataset is just handed to the ReportViewer control - so in that case it does not matter which data source you are using.

     

    For the datasource, you can expose them from the business object class as a dataset/datatable typed object, and just switch your datasource dynamically by adding some logic in your code.

     

    Thanks.

     

    Sincerely,
    Michael Jin.
    Microsoft Online Community Support

    “Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. ”
Page 1 of 1 (2 items)