Click here to Skip to main content
15,901,283 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am having dataset after certain manupulation , how could i assign it to reportviwer.
I am using VS 2010
Please
Posted

Microsoft.Reporting.WebForms.ReportDataSource Rds = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", ds.Tables[0]);
ReportViewer1.Reset();
ReportViewer1.LocalReport.Dispose();
ReportViewer1.LocalReport.DataSources.Add(Rds);
ReportViewer1.LocalReport.ReportPath = "Report2.rdlc";
ReportViewer1.DataBind();

This code bind the report datasource dynamically
 
Share this answer
 
Comments
Member 10420631 20-Apr-15 4:11am    
if you also have an ObjectDataSource, you can change ds.Tables[0] directly whith ("yourObjectDataSource") es.
Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", ObjectDataSource1);
good job
DataTable yearTable = new DataTable()
//now Bind DataTable


//here myRpt is ReportViewer id

myRpt.Load(Server.MapPath("myreport.rpt"));

if (yearTable != null)
{
myRpt.SetDataSource(yearTable);
myRpt.Refresh();
}
 
Share this answer
 
Comments
pawantiwari52 16-Nov-11 0:41am    
reportviewer does not have load method.
 
Share this answer
 
helo this is not a big problem... this is don here..
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 25-Jul-13 18:39pm    
How can you post it as "solution"? Have a shame.
—SA

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