リストがnullでないのに、オブジェクト参照がオブジェクトのインスタンスに設定されていません
protected void gridview_bind()
{
try
{
CompanyMasterClass co = new CompanyMasterClass();
co.strcompany_code = Request.Cookies["userinfo"]["companycode"].ToString();
ResultClass objress = co.fn_GetNameNumberStyle();
if (objress.bStatus)
{
eslist<CompanyMasterClass> OBJLISTS = objress.objData as eslist<CompanyMasterClass>;
if (OBJLISTS.Count > 0)
{
if (OBJLISTS[0].strdatestyle.ToString() == "DM")
{
mskextCreatedOn.Mask = "99/99/9999";
mskextCreatedOn.CultureName = "en-GB";
//mskextCreatedOn.UserDateFormat="DayMonthYear";
mskextUpdatedOn.Mask = "99/99/9999";
mskextUpdatedOn.CultureName = "en-GB";
}
if (OBJLISTS[0].strdatestyle.ToString() == "MD")
{
mskextCreatedOn.Mask = "99/99/9999";
mskextCreatedOn.CultureName = "en-US";
//mskextCreatedOn.UserDateFormat="DayMonthYear";
mskextUpdatedOn.Mask = "99/99/9999";
mskextUpdatedOn.CultureName = "en-US";
}
}
}
//mm.getlookup(ddlUserType, "user_type", "s");
CustomerMasterClass cs = new CustomerMasterClass();
ResultClass objres = cs.fn_GetCustomerMasterGrid();
if (objres.bStatus)
{
eslist<CustomerMasterClass> OBJLIST = objres.objData as eslist<CustomerMasterClass>;
if (OBJLIST.Count > 0)
{
if ((bool)ViewState["filter"] == true)
{
DataTable dts = (DataTable)ViewState["searchtable"];
pds.DataSource = dts.DefaultView;
pds.AllowPaging = true;
pds.PageSize = Convert.ToInt16(ddlPerPage.SelectedValue);
//pds.PageSize = 5;
DataView dvs = dts.DefaultView;
if (this.ViewState["SortExp"] != null)
{
dvs.Sort = this.ViewState["SortExp"].ToString()
+ " " + this.ViewState["SortOrder"].ToString();
}
pds.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pds.IsLastPage;
lnkbtnPrevious.Enabled = !pds.IsFirstPage;
if (pds.IsLastPage)
{
//lnkbtnNext.Style.Add("color", "#CCCCCC");
lnkbtnNext.Style.Add("background-color", "#CCCCCC");
lnkbtnNext.Style.Add("border-width", "0px");
}
else
{
//lnkbtnNext.Style.Remove("color");
lnkbtnNext.Style.Remove("background-color");
lnkbtnNext.Style.Remove("border-width");
}
if (pds.IsFirstPage)
{
//lnkbtnPrevious.Style.Add("color", "#CCCCCC");
lnkbtnPrevious.Style.Add("background-color", "#CCCCCC");
lnkbtnPrevious.Style.Add("border-width", "0px");
}
else
{
//lnkbtnPrevious.Style.Remove("color");
lnkbtnPrevious.Style.Remove("background-color");
lnkbtnPrevious.Style.Remove("border-width");
}
gvCustomerMaster.DataSource = pds;
gvCustomerMaster.DataBind();
doPaging();
// gvGroupMaster.DataSource = OBJLIST;
//gvGroupMaster.DataBind();
gridmain.Visible = true;
//frmvwGroup.Visible = false;
lblTotalRecords.Text = dts.Rows.Count.ToString();
}
else
{
DataTable dt = (DataTable)OBJLIST;
//dt = OBJLIST.ToString();
ViewState["nosearch"] = dt;
pds.DataSource = dt.DefaultView;
pds.AllowPaging = true;
pds.PageSize = Convert.ToInt16(ddlPerPage.SelectedValue);
//pds.PageSize = 5;
DataView dv = dt.DefaultView;
if (this.ViewState["SortExp"] != null)
{
dv.Sort = this.ViewState["SortExp"].ToString()
+ " " + this.ViewState["SortOrder"].ToString();
}
pds.CurrentPageIndex = CurrentPage;
lnkbtnNext.Enabled = !pds.IsLastPage;
lnkbtnPrevious.Enabled = !pds.IsFirstPage;
if (pds.IsLastPage)
{
//lnkbtnNext.Style.Add("color", "#CCCCCC");
lnkbtnNext.Style.Add("background-color", "#CCCCCC");
lnkbtnNext.Style.Add("border-width", "0px");
}
else
{
//lnkbtnNext.Style.Remove("color");
lnkbtnNext.Style.Remove("background-color");
lnkbtnNext.Style.Remove("border-width");
}
if (pds.IsFirstPage)
{
//lnkbtnPrevious.Style.Add("color", "#CCCCCC");
lnkbtnPrevious.Style.Add("background-color", "#CCCCCC");
lnkbtnPrevious.Style.Add("border-width", "0px");
}
else
{
//lnkbtnPrevious.Style.Remove("color");
lnkbtnPrevious.Style.Remove("background-color");
lnkbtnPrevious.Style.Remove("border-width");
}
gvCustomerMaster.DataSource = pds;
gvCustomerMaster.DataBind();
doPaging();
// gvGroupMaster.DataSource = OBJLIST;
//gvGroupMaster.DataBind();
gridmain.Visible = true;
//frmvwGroup.Visible = false;
lblTotalRecords.Text = OBJLIST.Count.ToString();
//this.GetUsersPageWise(1);
}
}
}
}
catch (Exception ex)
{
ErrorLogClass ObjError = new ErrorLogClass("customer_master.aspx", "customer_master()", ex);
}
}
DataTable dt =(DataTable)OBJLIST;でエラーが発生します。else節で。
何かアイデアや提案をお願いしますか?
ありがとう、