I am use crystal report and fetch data from stored procedure but when use this in page onload function it will be work in proper manner but not in static function, it show Error in last line: "Object reference not set to an instance of an object.
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;
}