即使我的列表不为空,我也没有将对象引用设置为对象的实例
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 子句中。
请问有什么想法或建议吗?
谢谢,