首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

rdlc查询结果的有关问题

2013-12-26 
rdlc查询结果的问题var dt new DataTable(CaseReport)dt.Columns.AddRange(new[]{new DataColumn(Cu

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();



代码如下,最后的dt是3条记录,为什么显示的时候只显示一条记录呢?求教各位大神
[解决办法]
定义一个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();

[解决办法]
是不是前端rdlc设计的没设置好?
[解决办法]
 调试走一下,代码似乎没问题   赞同一楼的,你直接给个model很麻烦吗?
[解决办法]
 rdlc设计的时候行有一个字段作为group,如果那个字段里的数据都一样就只有一条

热点排行