none
Add "DataView" to ReportViewer at Run-Time RRS feed

  • Question

  • Problem is briefly: select a group of rows based on date range, from that group select a sample of rows; print the sample.

    The selection process works correctly. I used a dataGrid to display the results. Someone suggested using a dataView to include just the rows chosen for the sample. That worked well also.

    I have created an RDLC file to display\print the sample and need to bind the dataView as the dataSource. There is lots of information about this but I seem to be missing a piece. RDLC's, as far as I can tell, need to have a dataSet and dataTable assigned as the dataSource. I have found how to create a dataSet. But I am not sure how to add a table.

    I have found the properties necessary to identify the reportDataSource, but I am really confused about how to do it correctly. I have included the code below that I am trying to use. The assignment to DS.Name is a holdover from when I was programmatically creating a dataSet and dataTable. (I changed "dt" to "DataTable1" is part of my experimentation.)

    As always, any nudge is much appreciated.

    DataView V1 = new DataView(R2); V1.RowFilter = "mark='X'"; //'mark' is a column in R2 DataTable dt = V1.ToTable(); //Create table for reportDataSource ReportDataSource DS = new ReportDataSource(); DS.Name = "DataSet1_DataTable1"; DS.Value = dt; reportViewer1.Reset();

    reportViewer1.LocalReport.DataSources.Clear();

    reportViewer1.LocalReport.DataSources.Add(DS); reportViewer1.RefreshReport();


    • Moved by Barry Wang Monday, September 1, 2014 7:25 AM RDLC related
    Friday, August 29, 2014 5:33 PM

Answers

  • Hi wodders,

    I think Visual Studio Report Controls will be better for your issue.

    Actually I gave you DataView before is because that is a WinForm API and you posted on WinForm forum. But I'm not so sure if a DataView can be applied by your ReportViewer.

    I have do some research about this issue and maybe you can have a look at this thread:

    http://stackoverflow.com/questions/424764/sorting-report-data-in-a-reportviewer-using-a-bindingsource

     ReportViewer1.Reset()
        Dim dt As DataTable
        dt = DirectCast(Form1.ProgActnBindingSource.Current, DataRowView).DataView.ToTable
    
        Dim rs = New ReportDataSource
        rs.Name = "name"
        rs.Value = dt
    
        ReportViewer1.ProcessingMode = ProcessingMode.Local
        ReportViewer1.LocalReport.DataSources.Clear()
        ReportViewer1.LocalReport.DataSources.Add(rs)
        ReportViewer1.LocalReport.ReportEmbeddedResource = "projectname.Report1.rdlc"
    
        Me.ReportViewer1.RefreshReport()

    Sounds related to your code especially for that convert part.

    Regards,



    Barry
    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.

    • Marked as answer by wodders Tuesday, September 2, 2014 1:44 PM
    Monday, September 1, 2014 7:32 AM