一个月前写好的一段代码,当时执行是完全没有问题的,昨天重新打开,运行时报表控件报错“ 不支持所指定的方法。”,跟踪调试发现WebViewer控件的LocateDataSource事件代码没有被执行,把事件绑定语句写在Page_load事件里也是不行。
页面的所有代码:
public partial class PrtAllo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
LoadPageReport();
if (System.Web.HttpContext.Current.Request.QueryString["IDS"] != null)
{
HiddenField1.Value = System.Web.HttpContext.Current.Request.QueryString["IDS"];
}
else
{
HiddenField1.Value = "0";
}
WebViewer1.LocateDataSource += new GrapeCity.ActiveReports.LocateDataSourceEventHandler(WebViewer1_LocateDataSource);
}
private void LoadPageReport()
{
GrapeCity.ActiveReports.PageReport report1 = null;
report1 = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(Server.MapPath("/Print/AllocationSheet.rdlx")));
WebViewer1.Report = report1;
}
protected void WebViewer1_LocateDataSource(object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args)
{
string connStr = ConfigurationManager.ConnectionStrings["sqlconn"].ConnectionString;
string ids = HiddenField1.Value;
if (ids.EndsWith(","))
{
ids = ids.Substring(0, ids.Length - 1);
}
string querySQL = "select * from view_allocationsheetdetail where as_id in("+ids+")";
DataSet ds = new DataSet();
LoadDataToDataSet(connStr, querySQL, ds, "Table1");
args.Data = ds.Tables[0];
}
private void LoadDataToDataSet(string connStr, string productSql, DataSet dataSetData, string tableName)
{
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(productSql, conn);
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = cmd;
adapter.Fill(dataSetData, tableName);
}
} |
|