rdlc查询结果的问题
var dt = new DataTable("CaseReport");
dt.Columns.AddRange(new[]{
new DataColumn("Customer"),
new DataColumn("UserName"),
new DataColumn("TotalMoney"),
new DataColumn("Money1"),
new DataColumn("Time1"),
new DataColumn("Money2"),
new DataColumn("Time2"),
new DataColumn("Moeny3"),
new DataColumn("Time3"),
new DataColumn("Money4"),
new DataColumn("Time4"),
new DataColumn("Money5"),
new DataColumn("Time5"),
new DataColumn("Money6"),
new DataColumn("Time6"),
new DataColumn("NextMoney"),
new DataColumn("NextTime"),
new DataColumn("Remark"),
});
foreach (var row in pro)
{
var r = dt.NewRow();
r.SetField(0, row.Information);
r.SetField(1, row.UserName);
r.SetField(2, row.TotalMoney);
r.SetField(3, row.Money1);
r.SetField(4, row.Time1);
r.SetField(5, row.Money2);
r.SetField(6, row.Time2);
r.SetField(7, row.Moeny3);
r.SetField(8, row.Time3);
r.SetField(9, row.Money4);
r.SetField(10, row.Time4);
r.SetField(11, row.Money5);
r.SetField(12, row.Time5);
r.SetField(13, row.Money6);
r.SetField(14, row.Time6);
r.SetField(15, row.NextMoney);
r.SetField(16, row.NextTime);
r.SetField(17, row.Remark);
dt.Rows.Add(r);
}
ReportViewer1.ProcessingMode = ProcessingMode.Local;
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
ReportViewer1.LocalReport.Refresh();
定义一个DataTable不如定义一个类:
public class Customer
{
public string cust_no {get;set;}
public string cust_name {get;set;}
...........
........
}
List<Customer> list = new List<Customer>();
foreach (var row in pro)
{
Customer model = new Customer();
model.Information=row.Information;
model.UserName=row.UserName;
..........
....
list.Add(model);
}
ReportViewer1.ProcessingMode = list;
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt));
ReportViewer1.LocalReport.Refresh();