Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 24, 2012 05:31 AM by sanjay bathre
Member
15 Points
38 Posts
Oct 22, 2012 11:51 AM|LINK
i want to add the customer list to Report1.rdlc file,
what i did is, i added CustomerList.xsd file and added a DataTable to it
i filled that data table by the code written below,
but the data is not shown to report, please help
try { DataTable dt = new DataTable(); DataTable dt1 = new DataTable(); ds = cdobj.getCustomerListForDataset(); if (ds.Tables[0].Rows.Count > 0) {
dt1 = ds.Tables[0]; DataRow drow;
CustomerList cl = new CustomerList(); //CustomerList cl = cl.Tables["DataTable1"].Clear(); dt = cl.Tables["DataTable1"]; for (int i = 0; i < dt1.Rows.Count; i++) { drow = dt.NewRow(); drow[i] = dt1.Rows[i]; dt.Rows.Add(drow); } this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("test", cl)); } this.reportViewer1.RefreshReport(); } catch(Exception ex) { } }
129 Points
113 Posts
Oct 24, 2012 07:51 PM|LINK
Hello Sanjay,
I am not sure, but I feel that you are adding all the rows to datatable dt, but not updating cl.
Finally, you need to update cl, because that is the datasource for the report.
Hope I gave some useful information.
Oct 30, 2012 06:01 AM|LINK
thank you krishna for your reply, but it's not working after updating cl also.......
i also tried like this.....
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("test", dt));
Participant
1160 Points
316 Posts
Oct 30, 2012 11:20 AM|LINK
A couple of things:
1. Is your app a Windows Forms one? Because I see Microsoft.Reporting.WinForms.ReportDataSource which refers to the Report Viewer win forms edition.
2. What is the exact name you set up for the data source in the RDLC report? If it is e.g. DataSet1 then you must use that name in this line:
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", cl));
Otherwise reportviewer will not be able to do the binding.
Nov 24, 2012 05:31 AM|LINK
i got the problem, datatable dt is not being filled, thats why no data is shown to report
sanjay bathr...
Member
15 Points
38 Posts
data not added to .rdlc report file, need help
Oct 22, 2012 11:51 AM|LINK
i want to add the customer list to Report1.rdlc file,
what i did is, i added CustomerList.xsd file and added a DataTable to it
i filled that data table by the code written below,
but the data is not shown to report, please help
try
{
DataTable dt = new DataTable();
DataTable dt1 = new DataTable();
ds = cdobj.getCustomerListForDataset();
if (ds.Tables[0].Rows.Count > 0)
{
dt1 = ds.Tables[0];
DataRow drow;
CustomerList cl = new CustomerList();
//CustomerList cl =
cl.Tables["DataTable1"].Clear();
dt = cl.Tables["DataTable1"];
for (int i = 0; i < dt1.Rows.Count; i++)
{
drow = dt.NewRow();
drow[i] = dt1.Rows[i];
dt.Rows.Add(drow);
}
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("test", cl));
}
this.reportViewer1.RefreshReport();
}
catch(Exception ex)
{
}
}
krishna.bb
Member
129 Points
113 Posts
Re: data not added to .rdlc report file, need help
Oct 24, 2012 07:51 PM|LINK
Hello Sanjay,
I am not sure, but I feel that you are adding all the rows to datatable dt, but not updating cl.
Finally, you need to update cl, because that is the datasource for the report.
Hope I gave some useful information.
Krishna
sanjay bathr...
Member
15 Points
38 Posts
Re: data not added to .rdlc report file, need help
Oct 30, 2012 06:01 AM|LINK
thank you krishna for your reply, but it's not working after updating cl also.......
i also tried like this.....
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("test", dt));
Neodynamic
Participant
1160 Points
316 Posts
Re: data not added to .rdlc report file, need help
Oct 30, 2012 11:20 AM|LINK
A couple of things:
1. Is your app a Windows Forms one? Because I see Microsoft.Reporting.WinForms.ReportDataSource which refers to the Report Viewer win forms edition.
2. What is the exact name you set up for the data source in the RDLC report? If it is e.g. DataSet1 then you must use that name in this line:
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSet1", cl));
Otherwise reportviewer will not be able to do the binding.
sanjay bathr...
Member
15 Points
38 Posts
Re: data not added to .rdlc report file, need help
Nov 24, 2012 05:31 AM|LINK
i got the problem, datatable dt is not being filled, thats why no data is shown to report