protected void LoadData() { DataTable dt = null; if (_refreshData || Session["dtUserHardware"] == null) { WTS_User u = new WTS_User(this.UserId); dt = u.HardwareList_Get(); HttpContext.Current.Session["dtUserHardware"] = dt; } else { dt = (DataTable)HttpContext.Current.Session["dtUserHardware"]; } if (dt != null) { this.DCC = dt.Columns; Page.ClientScript.RegisterArrayDeclaration("_dcc", JsonConvert.SerializeObject(DCC, Newtonsoft.Json.Formatting.None)); DtHT = dt.Copy(); DtHT = DtHT.DefaultView.ToTable(true, new string[] { "HardwareTypeID", "HardwareType" }); 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(); } grdHardware.DataSource = dt; grdHardware.DataBind(); }