终于搞出来了。代码如下。
- public partial class MyPageReport : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- GrapeCity.ActiveReports.PageReport report1 = new GrapeCity.ActiveReports.PageReport();
- report1.Load(new FileInfo(Server.MapPath(@"~/Untitled.rdlx")));
- report1.Document.LocateDataSource += Document_LocateDataSource;
- WebViewer.Report = report1;
- }
- }
- void Document_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
- {
- args.Data = GetData();
- }
- private System.Data.DataTable GetData()
- {
- System.Data.DataTable dt = new System.Data.DataTable();
- dt.Columns.Add("Field1");
- dt.Columns.Add("Field2");
- dt.Columns.Add("Field3");
- for (int i = 1; i <=100; i++)
- {
- dt.Rows.Add(i, i+1, "adfsasdfas asdfawefrawefaw fawfaweQ3WAWERGAWEGAEWFGAWEFAWEF");
- }
- return dt;
- }
- }
复制代码
谢谢 |