简体   繁体   中英

How to Insert values to strongly typed DataSet from code and then show it from RDLC reporting page?

I have created an aspx page and added a Report viewer to it and script manager. I have also added a strongly typed DataSet file DataSet1.xsd in which there is a DataTable having 2 coloumns - Name and Designation. I have also used rdlc file which I have binded it with dataset1.

Now I want to put values to the data set from my code and then show it to report viewer.

aspx.cs code -

DataSet1 ds = new DataSet1();
DataRow dr = ds.DataTable1.NewRow();
ds.DataTable1.AddDataTable1Row("x","y");
this.ReportViewer1.LocalReport.Refresh();

I am not getting the values to the report.

You can add the DataSource to the Reportviewer from code behind. Try the following code.

ReportDataSource datasource = new ReportDataSource("TableName", ds.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM