i try to get report when user click on update.. scenario is there is edit button in gridview and also there is several records so when user click on this edit button then box appear furthermore there is several fields then user select report type from drop down now when user select report type and click on update button then report is display but when i debug error is occurred
What I have tried:
i try this code
protected void gvNR_NRListDevx_AfterPerformCallback(object sender, ASPxGridViewAfterPerformCallbackEventArgs e)
{
if (e.CallbackName == "STARTEDIT")
{
int index = ((ASPxGridView)sender).EditingRowVisibleIndex;
ViewState["FFID"] = ((ASPxGridView)sender).GetRowValues(((ASPxGridView)sender).FocusedRowIndex, "FormID");
ViewState["VID"] = ((ASPxGridView)sender).GetRowValues(((ASPxGridView)sender).FocusedRowIndex, "VID");
ViewState["DateTime"] = Convert.ToDateTime(((ASPxGridView)sender).GetRowValues(((ASPxGridView)sender).FocusedRowIndex, "DateTime"));
}
else if (e.CallbackName == "CANCELEDIT")
{
}
else if(e.CallbackName == "UPDATEEDIT")
{
DateTime DateT = (DateTime)ViewState["DateTime"];
string VehId = (string)ViewState["VID"];
_sys = new clsDe_ComplainMaster();
DataTable dtUpdated = _sys.SelectUpdatedNRtype(ViewState["FFID"].ToString(), VehId, DateT);
if (dtUpdated.Rows[0]["NRType"].ToString() == "0002")
{
printgpsreport(DateT, VehId, "REPORT1.rpt");
}
else if (dtUpdated.Rows[0]["NRType"].ToString() == "0011")
{
printgpsreport(DateT, VehId, "REPORT2.rpt");
}
public DataTable SelectUpdatedNRtype(string FormID , string VEhID, DateTime DateT)
{
string strSql = "select NRType from NR_NRType_LogHistory where FormID = '" + FormID + "' ANd VehicleID = '" + VEhID + "' AND NRDate = '" + DateT + "'";
return this.GetQueryData(strSql);
}
public DataSet getreport()
{
DataSet ds;
try
{
SqlParameter[] Params =
{
new SqlParameter("@datetime",SqlDbType.DateTime),
new SqlParameter("@VehID",SqlDbType.VarChar)
};
if ( datetime != null)
{
Params[0].Value = datetime;
}
else
{
Params[0].Value = DBNull.Value;
}
if (VehID != null)
{
Params[1].Value = VehID;
}
else
{
Params[1].Value = DBNull.Value;
}
ds = GetDataSet("sp_gps_report", Params);
return ds;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
ERROR IS OCCURRED ON THIS LINE
DateTime DateT = (DateTime)ViewState["DateTime"];
An exception of type 'System.NullReferenceException' occurred in ERP.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
any help please