Report viewer shows only one record at run time where there are 15 records present in my ds.tables[0

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi Everybody,
Im using report viewer in my application. When i select multiple items to view, it only shows first one.
This is my code:
cryrreport fc = new cryrreport();
DataSet a = new DataSet();
DataTable dtbl = new DataTable();

SqlDataAdapter adp = new SqlDataAdapter();
adp.SelectCommand = new SqlCommand();
adp.SelectCommand.Connection = con;

ListView.CheckedListViewItemCollection checkedItems = lvpayslip.CheckedItems;
foreach (ListViewItem item in checkedItems)
{
con = new SqlConnection(cn);
con.Open();

adp.SelectCommand.CommandText = "payslipfor1";
adp.SelectCommand.CommandType = CommandType.StoredProcedure;

adp.SelectCommand.Parameters.AddWithValue("@dbempid", Int32.Parse(item.SubItems[2].Text));
adp.SelectCommand.Parameters.AddWithValue("@dbmonth", item.SubItems[0].Text);
adp.SelectCommand.Parameters.AddWithValue("@dbyear", Int32.Parse(item.SubItems[1].Text));
adp.Fill(dtbl);

reportview f1 = new reportview();


//ReportDataSource source = new ReportDataSource("datatable1", dtbl);
f1.reportViewer1.Visible = true;
//f1.reportViewer1.ProcessingMode = ProcessingMode.Local;
//f1.reportViewer1.LocalReport.ReportPath = "Report1.rdlc";
f1.reportViewer1.LocalReport.DataSources.Clear();
ReportDataSource source = new ReportDataSource("DataSet1", dtbl);
f1.reportViewer1.LocalReport.DataSources.Add(source);
f1.reportViewer1.LocalReport.Refresh();

f1.Show();

View the full article
 
Back
Top