none
Create Temporary DataSet for RDLC RRS feed

  • Question

  • I need to create a table to use in a report. It is the only place is the application that this table is used. Up to now, in this situation, I have added a datatable to the data set, and referenced the datatable in report data. I can then drag the fields to the report definition. During execution, the table is populated, and used in the report.

    I am wondering if something like the following is possible:

    DataSet DS = new DataSet();
    DataTable DT = new DataTable();
    
    DT.Columns.Add("col1");
    DT.Columns.Add("col2");
    DT.Columns.Add("col3");
    
    DS.Tables.Add(DT);
    
    //Code to populate DT
    //Code to set up local report
    
    ReportDataSource RD = new ReportDataSource("DS", DT);
    
    reportViewer1.LocalReport.DataSources.Add(RD);

    I have tried something like this as an experiment. I do not get any errors. But I am unsure: (1) how to add the data source to the report data, and (2) as a result, how to reference the data table fields in the report definition.

    Possible? Not possible? Any nudge is appreciated.

    Thursday, March 10, 2016 4:28 PM

All replies

  • You can use a custom class/object, load the objects into a collection and bind the collection.  

    http://www.c-sharpcorner.com/UploadFile/mahesh/ReportViewerObject04172007111636AM/ReportViewerObject.aspx

    Thursday, March 10, 2016 9:44 PM
  • Hi wodders,

    This forum is about the C# programming language, IDE, libraries, samples, and tools. As your issue is more related to the RDLC application, we would help you move this thread to the Visual Studio Report Controls forum for better support. If you any issues about C# development, you are welcome to post them here.

    Thank you for your understanding and support.

    Best Regards,

    Albert Zhang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 11, 2016 2:30 AM