Last post Sep 12, 2017 01:19 AM by Deepak Panchal
Sep 11, 2017 05:55 PM|ASPBabe|LINK
There is a datatable displayed in a gridview that needs to be exported. How can that most simply be done thru a Local report in a Panel.
Please provide detailed instructions with code and examples. Thanks.
Sep 12, 2017 01:19 AM|Deepak Panchal|LINK
retrieve the data source from grid view.
BindingSource bs = (BindingSource)GridView1.DataSource;//You should first convert DataSourse into Binding Sourse
DataTable dt = (DataTable) bs.DataSource; //Get GridView data source to Data table
bind ReportViewer to DataTable.
ReportViewer ReportViewer1 = new ReportViewer(); //Your ReportViewer Control
ReportDataSource rds = new ReportDataSource("DataSet1_Customers_DataTable1",dt); // ReportViewerDataSource : ReportViewer is to be bind to this DataSource
ReportViewer1.LocalReport.DataSources.Clear(); // Clear the Previous DataSource of ReportViewer
ReportViewer1.LocalReport.DataSources.Add(rds); //bind ReportViewer1 to the new datasource(Which you wish)
ReportViewer1.LocalReport.Refresh(); // Refresh the ReportViewer Control, ReportViewer1 in this case