C# Crystal report无法在静态功能下工作
我正在使用crystal report并从存储过程中获取数据,但当在page onload函数中使用此函数时,它将以正确的方式工作,而不是在静态函数中,它在最后一行显示错误:“对象引用未设置为对象的实例C# Crystal report无法在静态功能下工作,c#,asp.net,sql-server-2008,crystal-reports,C#,Asp.net,Sql Server 2008,Crystal Reports,我正在使用crystal report并从存储过程中获取数据,但当在page onload函数中使用此函数时,它将以正确的方式工作,而不是在静态函数中,它在最后一行显示错误:“对象引用未设置为对象的实例 public static void DrawGrids() { ReportDocument rptDoc = new ReportDocument(); ComplaintTrackingSystem.Reports.D
public static void DrawGrids()
{
ReportDocument rptDoc = new ReportDocument();
ComplaintTrackingSystem.Reports.Datas dss = new Reports.Datas();
DataTable dt = new DataTable();
DataSet ds;
Hashtable ObjParameters = new Hashtable();
BusinessLogicLayer ObjBusiness = new BusinessLogicLayer();
ds =ObjBusiness.SPDataSet(ObjParameters,"SelectUserComplaintsByComptIdReport");
dt.TableName = "Crystal Report Example";
dt = ds.Tables[0]; //This function is located below this function
dss.Tables[0].Merge(dt);
rptDoc.Load(HttpContext.Current.Server.MapPath("../Reports/ComplaintReport.rpt"));
//set dataset to the report viewer.
rptDoc.SetDataSource(dss);
CrystalDecisions.Web.CrystalReportViewer obj = new CrystalDecisions.Web.CrystalReportViewer();
Page p = HttpContext.Current.Handler as Page;
obj = (CrystalDecisions.Web.CrystalReportViewer)p.FindControl("CrystalReportViewer1");
obj.ReportSource = rptDoc;
}
您在哪一行得到错误?obj.ReportSource=rptDoc;