Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi ,I want to bind dataset's data to ReportViewer object , I create rdlc report and set it as ReportViewer's report source is design view , but it doesn't show anything ,I checked dataset's data by binding gridview and it's work and show the data in gridview but in ReportViewer object doesn't , Please Help . Here is the code:(Note: "Temp" is the table's Name of database , that's i want to bind to ReportViewer)

string path = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated      Security=True";

SqlConnection con1 = new SqlConnection(path);
con1.Open();
const string query = "select * From [Table1] where date between @from and @to";
SqlCommand com1 = new SqlCommand(query, con1);
com1.Parameters.AddWithValue("@from", DateTime.Parse(r1));
com1.Parameters.AddWithValue("@to", DateTime.Parse(r2));
SqlDataAdapter adp1 = new SqlDataAdapter(com1);
DataSet ds1 = new DataSet();
adp1.Fill(ds1);
com1.ExecuteNonQuery();
con1.Close();


GridView1.DataSource = ds1;
GridView1.DataBind();

ReportViewer1.Reset();
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("Temp",    ds1.Tables[0]));

ReportViewer1.LocalReport.Refresh();
Posted

please create a new DataSet that the name is "DataSet1". It should be the default.Try and change your solution at like this

ReportViewer1.LocalReport.DataSources.Add(New ReportDataSource("Dataset1", ds1.Tables("DataTable1")))
 
Share this answer
 
v2
Comments
Member 11545639 5-Apr-15 12:34pm    
thank's for your solution , but i want to bind reportviewer without using XSD dataset items. is there a way to do that?
Ekona_Pikin 5-Apr-15 13:54pm    
So you are trying to create Dataset dynamically and passing to ReportViewer?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900