有很多DataSet,DataSet是DataSet_KaiBGS,是什么问题。
protected override void OnLocateDataSourceHandl ...
参考cs文件:核心代码:
using GrapeCity.ActiveReports;
using GrapeCity.ActiveReports.Extensibility.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace ActiveReports10_Mvc4
{
/// <summary>
/// Summary description for CustomService
/// </summary>
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
public class ActiveReportsService : GrapeCity.ActiveReports.Web.ReportService
{
protected override object OnCreateReportHandler(string reportPath)
{
var instance = base.OnCreateReportHandler(reportPath);
var pageReport = instance as PageReport;
if (pageReport != null)
{
pageReport.Document.LocateDataSource += Document_LocateDataSource;
}
return instance;
}
void Document_LocateDataSource(object sender, LocateDataSourceEventArgs args)
{
if (args.DataSourceName == "DataSource1" & args.DataSetName == "DataSet1")
args.Data = GetObjectDataSource();
if (args.DataSourceName == "DataSource1" & args.DataSetName == "DataSet2")
args.Data = GetData();
}
private object GetObjectDataSource()
{
List<CustomObject> data = new List<CustomObject>();
data.Add(new CustomObject { Name = "car", Description = "car description" });
data.Add(new CustomObject { Name = "bike", Description = "bike description" });
return data;
}
private object GetData()
{
List<CustomObject> data = new List<CustomObject>();
data.Add(new CustomObject { Name = "car", Description = "car description" });
data.Add(new CustomObject { Name = "bike", Description = "bike description" });
return data;
}
}
public class CustomObject
{
public string Name { get; set; }
public string Description { get; set; }
}
}
void Document_LocateDataSource(object sender, LocateDataSourceEventArgs args)
这个方法,有几个DataSet就应该执行几次。
我的只执行了,一次。是哪的问题。我有4个DataSet,仅执行了,1次 bjqxst 发表于 2016-4-13 17:57
void Document_LocateDataSource(object sender, LocateDataSourceEventArgs args)
这个方法,有几个DataS ...
现在的问题是,报表中包含多个DataSet,无法正常加载到报表中?
因为无法判断是什么原因导致的,还请您上传下Demo程序,我在这边验证下 Demo做好了,可以运行测试。我测试了,多个数据集的时候,确实只执行了一次,不知道为什么,你看看什么原因。
下面这个方法,有几个DataSet就应该执行几次啊,我的只执行了,一次,找找哪出问题了。
void Document_LocateDataSource(object sender, LocateDataSourceEventArgs args)
{
//招标统计
if (args.DataSourceName == "DataSource_Tender")
{
//公告个数
if (args.DataSetName == "DataSet_GongGGS")
{
args.Data = GetTenderDataSource();
}
//开标个数
if (args.DataSetName == "DataSet_KaiBGS")
{
args.Data = GetTenderDataSource_KaiBBS();
}
}
}
本帖最后由 Lenka.Guo 于 2016-4-15 15:28 编辑
bjqxst 发表于 2016-4-14 18:42
Demo做好了,可以运行测试。我测试了,多个数据集的时候,确实只执行了一次,不知道为什么,你看看什么原因 ...
hi, 我把您的Demo下载下来测试了,报表的数据都能正常加载。您那边也是一样的吧?
这个函数在不同的WebViewer下,执行的机制不一样。
我在4# 给您的Demo,使用的是WebViewer;所以必须在webpage.aspx.cs 文件中实现 动态数据源绑定;
而您使用的是HTML5Viewer,需要在WebService.asmx文件中绑定数据源,而服务文件是一次性请求,是在创建报表的时候,会将所有数据集绑定。
谢谢了,你写个报表模板的,例子,发给我吧 本帖最后由 Lenka.Guo 于 2016-4-15 15:54 编辑
Lenka.Guo 发表于 2016-4-15 14:47
hi, 我把您的Demo下载下来测试了,报表的数据都能正常加载。您那边也是一样的吧?
如电话所沟通:
未能正确加载多个数据集,是因为报表模板的类型导致的;
页面报表:每页只能对应一个DataSet,不支持多数据集绑定;
Rdl报表,支持多数据源,多数据集绑定。
因此如果您需要在同一张报表中,绑定多个数据集,建议您选择 Rdl报表模板。
示例程序:(我使用的是ActiveReports 10 SP1 如版本号不对,请使用VS 工具->转换为ActiveReports10,一键升级)
入门教程:
ActiveReports 报表控件官方中文入门教程 (3)-如何选择页面报表和区域报表
可以了。用报表模板就oK了。谢谢了。 bjqxst 发表于 2016-4-15 16:36
可以了。用报表模板就oK了。谢谢了。
:hjyzw:
页:
1
[2]