Пример #1
0
    protected void FillGrid()
    {
        DataTable dt = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "BookingUnavailabilityReason", "", "booking_unavailability_reason_type_id, descr", "booking_unavailability_reason_id", "booking_unavailability_reason_type_id", "descr");

        Session["bookingunavailabilityreason_data"] = dt;

        if (dt.Rows.Count > 0)
        {
            GrdBookingUnavailabilityReason.DataSource = dt;
            try
            {
                GrdBookingUnavailabilityReason.DataBind();
            }
            catch (Exception ex)
            {
                SetErrorMessage("", ex.ToString());
            }
        }
        else
        {
            dt.Rows.Add(dt.NewRow());
            GrdBookingUnavailabilityReason.DataSource = dt;
            GrdBookingUnavailabilityReason.DataBind();

            int TotalColumns = GrdBookingUnavailabilityReason.Rows[0].Cells.Count;
            GrdBookingUnavailabilityReason.Rows[0].Cells.Clear();
            GrdBookingUnavailabilityReason.Rows[0].Cells.Add(new TableCell());
            GrdBookingUnavailabilityReason.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdBookingUnavailabilityReason.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
Пример #2
0
    protected void Sort(string sortExpression, params string[] sortExpr)
    {
        DataTable dataTable = Session["bookingunavailabilityreason_data"] as DataTable;

        if (dataTable != null)
        {
            if (Session["bookingunavailabilityreason_sortexpression"] == null)
            {
                Session["bookingunavailabilityreason_sortexpression"] = "";
            }

            DataView dataView = new DataView(dataTable);
            string[] sortData = Session["bookingunavailabilityreason_sortexpression"].ToString().Trim().Split(' ');

            string newSortExpr = (sortExpr.Length == 0) ?
                                 (sortExpression == sortData[0] && sortData[1] == "ASC") ? "DESC" : "ASC" :
                                 sortExpr[0];

            dataView.Sort = sortExpression + " " + newSortExpr;
            Session["bookingunavailabilityreason_sortexpression"] = sortExpression + " " + newSortExpr;

            GrdBookingUnavailabilityReason.DataSource = dataView;
            GrdBookingUnavailabilityReason.DataBind();
        }
    }