devexpress XtraReport报表代码绑定教程
一.直接找字段标签绑定
报表类实例化
tl_tlsoft_Qlcheck_qlReport report = new tl_tlsoft_Qlcheck_qlReport();
string tmpurl = Application.StartupPath + "\\report\\Report1.repx";
report.LoadLayout(tmpurl); //为存储到根目录下报表
1.1 方法1开始查找控件
List<QlbaseZD> ql = QlbaseSER.GetQlbase("1");
report.FindControl("tableCell23", false).Text = ql.Count.ToString();
1.2 方法2
// report.FindControl("tableCell24", false).DataBindings.Add(new DevExpress.XtraReports.UI.XRBinding("Text", datb, "qlid", "")); //这里面的Text是xrtable的属性 区分大小写
二、通过区域控件绑定,前提是要对区域内先填好字段数据。然后直接绑定,主要用于多条循环的情况,如表格等。
//2方法2
先按条件查出表格,然后绑定
DataTable datdlwzpic = qlfjpicSER.QueryTAB(cqlid).Tables[0];
DetailReportBand DetailReport = report.FindControl("DetailReport6", true) as DetailReportBand;
DetailReport.DataSource = datdlwzpic;
DetailReport.DataMember = "ds";
2.2 通过DetailBand没有试过
//DetailBand Detail1 = report.FindControl("Detail4", true) as DetailBand;