protected void FillGrid() { DataTable dt = BookingChangeHistoryReasonDB.GetDataTable(); Session["bookingchangehistoryreason_data"] = dt; if (dt.Rows.Count > 0) { GrdBookingChangeHistoryReason.DataSource = dt; try { GrdBookingChangeHistoryReason.DataBind(); } catch (Exception ex) { SetErrorMessage("", ex.ToString()); } } else { dt.Rows.Add(dt.NewRow()); GrdBookingChangeHistoryReason.DataSource = dt; GrdBookingChangeHistoryReason.DataBind(); int TotalColumns = GrdBookingChangeHistoryReason.Rows[0].Cells.Count; GrdBookingChangeHistoryReason.Rows[0].Cells.Clear(); GrdBookingChangeHistoryReason.Rows[0].Cells.Add(new TableCell()); GrdBookingChangeHistoryReason.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdBookingChangeHistoryReason.Rows[0].Cells[0].Text = "No Record Found"; } }
protected void Sort(string sortExpression, params string[] sortExpr) { DataTable dataTable = Session["bookingchangehistoryreason_data"] as DataTable; if (dataTable != null) { if (Session["bookingchangehistoryreason_sortexpression"] == null) { Session["bookingchangehistoryreason_sortexpression"] = ""; } DataView dataView = new DataView(dataTable); string[] sortData = Session["bookingchangehistoryreason_sortexpression"].ToString().Trim().Split(' '); string newSortExpr = (sortExpr.Length == 0) ? (sortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC" : sortExpr[0]; dataView.Sort = sortExpression + " " + newSortExpr; Session["bookingchangehistoryreason_sortexpression"] = sortExpression + " " + newSortExpr; GrdBookingChangeHistoryReason.DataSource = dataView; GrdBookingChangeHistoryReason.DataBind(); } }