public DataSet Get_ItemCatalogueRecords() { SqlCommand cmd_ItemCatalogue = new SqlCommand(); cmd_ItemCatalogue.CommandText = "[VRM].[GET_ItemCatalogueRecords]"; cmd_ItemCatalogue.CommandType = CommandType.StoredProcedure; cmd_ItemCatalogue.Parameters.Clear(); DataSet ds_ItemCatalogue = getDataSet(cmd_ItemCatalogue);-->Sometimes this sentence is in error state. return ds_ItemCatalogue; }
private void BindGrid(bool Reload) { DataTable dtItemCatalogueRecords = null; if (Reload) { dtItemCatalogueRecords = GET_ItemCatalogueRecords().Tables[0]; } else { //retrieve the ViewState object datatable dtItemCatalogueRecords = ViewState[viewStateGVName] as DataTable; dtItemCatalogueRecords.DefaultView.Sort = ViewState[this.ToString() + "_SortExpression"].ToString() + " " + ViewState[this.ToString() + "_SortDirection"].ToString(); } if (dtItemCatalogueRecords != null) { if (dtItemCatalogueRecords.Rows.Count > 0) { ViewState[viewStateGVName] = dtContractTemplateRecords; gvItemCat.DataSource = ViewState[viewStateGVName]; gvItemCat.AllowSorting = true; gvItemCat.DataBind(); } else { dtItemCatalogueRecords.Rows.Add(dtItemCatalogueRecords.NewRow()); ViewState[viewStateGVName] =dtItemCatalogueRecords; gvItemCat.DataSource = ViewState[viewStateGVName]; gvItemCat.AllowSorting = false; gvItemCat.DataBind(); int TotalColumns = gvItemCat.Rows[0].Cells.Count; gvItemCat.Rows[0].Cells.Clear(); gvItemCat.Rows[0].Cells.Add(new TableCell()); gvItemCat.Rows[0].Cells[0].ColumnSpan = TotalColumns; gvItemCat.Rows[0].Cells[0].Text = "No Record Found"; } } }