예제 #1
0
    protected void FillGrid()
    {
        DataTable dt = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "OrganisationCustomerType", "organisation_customer_type_id NOT IN (0,139,275)", "descr", "organisation_customer_type_id", "descr");

        Session["organisationcustomertype_data"] = dt;

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

            int TotalColumns = GrdOrganisationCustomerType.Rows[0].Cells.Count;
            GrdOrganisationCustomerType.Rows[0].Cells.Clear();
            GrdOrganisationCustomerType.Rows[0].Cells.Add(new TableCell());
            GrdOrganisationCustomerType.Rows[0].Cells[0].ColumnSpan = TotalColumns;
            GrdOrganisationCustomerType.Rows[0].Cells[0].Text       = "No Record Found";
        }
    }
예제 #2
0
    protected void Sort(string sortExpression, params string[] sortExpr)
    {
        DataTable dataTable = Session["organisationcustomertype_data"] as DataTable;

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

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

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

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

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