本帖最后由 Lenka.Guo 于 2016-11-29 11:57 编辑
List数据源绑定参考博客: http://blog.gcpowertools.com.cn/ ... ListDataSource.aspx
Web写法如下:
PageReport rpt= new PageReport("....");
Report.Document.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(document_LocateDataSource);
webViewer.Report=rpt
- void document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
- {
- if (args.DataSourceName == "ListDataSource" && args.DataSetName == "ListDataSet")
- {
- args.Data = GetData();
- }
- }
- private List<Product> GetData()
- {
- List<Product> list = new List<Product>();
- for (int i = 1; i <= 20; i++)
- {
- list.Add(new Product(){ID=i,Name="产品"+i.ToString(),Price =i * 10f,Stock=i * 20});
- }
- return list;
- }
复制代码
|