以上是我的报表模版
下面的是我动态给定数据源的方法。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace WebApplication4.Report
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath(string.Format("~/Report/111.rdlx"))));
WebViewer1.Report = rpt;
}
private DataTable GetDataCondtion(string ss)
{
DataTable dt = new DataTable();
dt.Columns.Add("IOrder");
dt.Columns.Add("TextContent");
dt.Rows.Add("1", "2");
return dt;
}
private DataTable GetDataMultiPay()
{
DataTable dt = new DataTable();
dt.Columns.Add("skuanxiang");
dt.Columns.Add("smoney",typeof(double));
dt.Columns.Add("smoneyCapital");
dt.Columns.Add("spayConditionNo");
dt.Columns.Add("sjkPayConditionNo");
dt.Columns.Add("scount");
dt.Rows.Add("322", 222, "2", "22222","2");
return dt;
}
private DataTable GetDataFinalPay()
{
DataTable dt = new DataTable();
dt.Columns.Add("dmoney",typeof(double));
dt.Columns.Add("smoneyCapital");
dt.Columns.Add("dpercent");
dt.Columns.Add("ipaySlc");
dt.Columns.Add("siginText1");
dt.Columns.Add("siginText2");
dt.Rows.Add(2, "222", "2", "22222","222","32333");
return dt;
}
private DataTable GetDataFirstPay()
{
DataTable dt = new DataTable();
dt.Columns.Add("dmoney",typeof(double));
dt.Columns.Add("smoneyCapital");
dt.Columns.Add("dpercent");
dt.Columns.Add("stext");
dt.Rows.Add(2,"222","2","22222");
return dt;
}
private DataTable GetDataPrice()
{
DataTable dt = new DataTable();
dt.Columns.Add("dquipmentTotalPrice");
dt.Columns.Add("squipmentTotalPriceCapital");
dt.Columns.Add("ipriceSlc");
dt.Rows.Add("1","2","3");
return dt;
}
private DataTable GetDataCost()
{
DataTable dt = new DataTable();
dt.Columns.Add("dquipmentCost",typeof(double));
dt.Columns.Add("squipmentCostCapital");
dt.Rows.Add(1, "2");
return dt;
}
private DataTable GetDataContract()
{
DataTable dt = new DataTable();
dt.Columns.Add("scontractNo");
dt.Columns.Add("sconstractName");
dt.Columns.Add("scontractNote");
dt.Rows.Add("1","2","23");
return dt;
}
private DataTable GetDataFrameText()
{
DataTable dt = new DataTable();
dt.Columns.Add("sdealtext");
dt.Rows.Add("12");
return dt;
}
private DataTable GetThirdPart()
{
DataTable dt = new DataTable();
dt.Columns.Add("sname");
dt.Columns.Add("saddress");
dt.Columns.Add("sartificialPersonName");
dt.Columns.Add("slinkman");
dt.Columns.Add("spostno");
dt.Columns.Add("sfax");
dt.Columns.Add("sphone");
dt.Columns.Add("semail");
dt.Rows.Add("第三方公司","陕西省西安市高新区高新三路128号","唐三藏","孙悟空","7100075","029-88293301","13720877564","123@mail.qq.com");
return dt;
}
private DataTable GetTransDataMain()
{
DataTable dt = new DataTable();
dt.Columns.Add("CtNo");
dt.Columns.Add("TitleText");
dt.Columns.Add("FirstPart");
dt.Columns.Add("SecondPart");
dt.Columns.Add("DealEqText");
dt.Columns.Add("SpecialAgreement");
dt.Rows.Add("1","2","3","4","5","6");
return dt;
}
protected void WebViewer1_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
{
if (args.DataSourceName == "DataSource1")
{
if (args.DataSetName == "DataMain")
{
args.Data = GetTransDataMain();
}
else if (args.DataSetName == "DataThird")
{
args.Data = GetThirdPart();
}
else if (args.DataSetName == "DataFrameText")
{
args.Data = GetDataFrameText();
}
else if (args.DataSetName == "DataContract")
{
args.Data = GetDataContract();
}
else if (args.DataSetName == "DataCost")
{
args.Data = GetDataCost();
}
else if (args.DataSetName == "DataPrice")
{
args.Data = GetDataPrice();
}
else if (args.DataSetName == "DataFirstPay")
{
args.Data = GetDataFirstPay();
}
else if (args.DataSetName == "DataFinalPay")
{
args.Data = GetDataFinalPay();
}
else if (args.DataSetName == "DataMultiPay")
{
args.Data = GetDataMultiPay();
}
else if (args.DataSetName == "DataPayCondtion")
{
args.Data = GetDataCondtion("2");
}
else if (args.DataSetName == "DataJkCondtion")
{
args.Data = GetDataCondtion("2");
}
}
}
}
} |