Answer the question
In order to leave comments, you need to log in
How to display contents of DataTable in ReportViewer?
So far there is this code:
DataTable dt = new DataTable();
dt.TableName = "DataTable1";
string str = "OrderDetails " + Convert.ToString(onumber);
SqlDataAdapter adapter = new SqlDataAdapter(str, Data.connectionString);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(adapter);
adapter.Fill(dt);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
reportViewer1.Visible = true;
reportViewer1.LocalReport.DataSources.Clear();
ReportDataSource reportInfo = new ReportDataSource("DataTable1", dt);
reportInfo.Value = ds.Tables[0];
reportViewer1.LocalReport.DataSources.Add(reportInfo);
reportViewer1.Refresh();
Answer the question
In order to leave comments, you need to log in
Do you have a problem only with replacing the data source? Then in my opinion you have no problem - you created it yourself. Reports can be built on a typical data source based on incoming parameters. And that's pretty much what you should do. Based on the data source slipped into the wizard, a simple template with a table is generated based on the considerations that this is all that will be in the report. The data source remains the same all the time, but the parameters for generating the report are already different.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question