예제 #1
0
    public static void CustomPaging(ref Telerik.Web.UI.RadGrid objDataGrid, GridViewPageEventArgs e, System.Data.DataTable dt)
    {
        if (objDataGrid != null)
        {
            if (dt != null)
            {
                DataView dv = new DataView(dt);
                dv.Sort = objDataGrid.Attributes["SortExpression"];
                if (objDataGrid.Attributes["SortASC"] == "No")
                {
                    dv.Sort += " DESC";
                }

                //objDataGrid.PageIndex = e.NewPageIndex;
                //objDataGrid.CurrentPageIndex = e.NewPageIndex;
                objDataGrid.DataSource = dv;
                objDataGrid.DataBind();

                if (objDataGrid.CurrentPageIndex == objDataGrid.PageCount - 1 & (dt.Rows.Count / objDataGrid.PageSize) <= objDataGrid.CurrentPageIndex)
                {
                    objDataGrid.CurrentPageIndex = objDataGrid.CurrentPageIndex - 1;
                }
            }
        }
    }
        private void GetFilteredGrid()
        {
            //DataSet dataSet  =  (DataSet) Cache["PageTableCache"];

            if ((string)Session["SelectedPublication"] == "")
            {
                lblChooseProduct.Visible = true;
                return;
            }
            lblChooseProduct.Visible = false;

            CCDBaccess db = new CCDBaccess();

            string    errmsg = "";
            DataTable tbl    = null;

            tbl = db.GetTablePageStatusCollection((bool)Session["HideFinished"], out errmsg);

            if (tbl != null)
            {
                int rowCount = tbl.Rows.Count;

                if (rowCount > 20)
                {
                    int n2 = rowCount / 2;

                    for (int i = 0; i < n2; i++)
                    {
                        for (int j = 0; j < 12; j++)
                        {
                            tbl.Rows[i][j + 13] = tbl.Rows[i + n2][j];
                        }
                    }

                    for (int i = rowCount - 1; i >= n2; i--)
                    {
                        tbl.Rows[i].Delete();
                    }
                }

                lblError.Text = "";

                RadGrid1.DataSource = tbl;
                RadGrid1.DataBind();
            }
            else
            {
                lblError.Text = errmsg;
            }
        }
예제 #3
0
    public static void CustomSorting(ref Telerik.Web.UI.RadGrid objDataGrid, System.Web.UI.WebControls.GridViewSortEventArgs e, System.Data.DataTable dt)
    {
        if (objDataGrid != null)
        {
            if (dt != null)
            {
                //DataGrid dgActivityStatus = ((System.Web.UI.WebControls.DataGrid)source);

                object strSort = objDataGrid.Attributes["SortExpression"];
                object strASC  = objDataGrid.Attributes["SortASC"];

                objDataGrid.Attributes["SortExpression"] = e.SortExpression;
                objDataGrid.Attributes["SortASC"]        = "Yes";
                if (Convert.ToString(e.SortExpression) == Convert.ToString(strSort))
                {
                    if (Convert.ToString(strASC) == "Yes")
                    {
                        objDataGrid.Attributes["SortASC"] = "No";
                    }
                    else
                    {
                        objDataGrid.Attributes["SortASC"] = "Yes";
                    }
                }

                DataView dv = dt.DefaultView;
                dv.Sort = objDataGrid.Attributes["SortExpression"];
                if (objDataGrid.Attributes["SortASC"] == "No")
                {
                    dv.Sort = dv.Sort + " " + "DESC";
                }


                objDataGrid.DataSource = dv;
                objDataGrid.DataBind();
            }
        }
    }