private void loadGridData() { DataTable dt = null; if (_refreshData || Session["ALLOCATION"] == null) { dt = MasterData.ALLOCATION_GETALL(); HttpContext.Current.Session["ALLOCATION"] = dt; } else { dt = (DataTable)HttpContext.Current.Session["ALLOCATION"]; } if (dt != null) { this.DCC = dt.Columns; Page.ClientScript.RegisterArrayDeclaration("_dcc", JsonConvert.SerializeObject(DCC, Newtonsoft.Json.Formatting.None)); spanRowCount.InnerText = dt.Rows.Count.ToString(); ListItem item = ddlQF.Items.FindByValue(_qfAllocationCategoryID.ToString()); if (item != null) { item.Selected = true; } InitializeColumnData(ref dt); dt.AcceptChanges(); int count = dt.Rows.Count; count = count > 0 ? count - 1 : count; //need to subtract the empty row spanRowCount.InnerText = count.ToString(); } grdMD.DataSource = dt; grdMD.DataBind(); }