How to Current Selected page of RadGrid

5 posts, 0 answers
  1. CHETAN JAITLY
    CHETAN JAITLY avatar
    16 posts
    Member since:
    Jan 2009

    Posted 17 Feb 2009 Link to this post

    Hi
    I have RadGrid Control on the page which consist more then 100 pages.
    I have to highlight current selected page so that business user can have track of current page .

    Can you suggest for the same.


    Thanks
    Shrirang
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Feb 2009 Link to this post

    Hi Chethan,

    Here is the code snippet to highlight the current page number in the Grid pager. Give a try with the following code and see if it meets your requirement.

    ASPX:
     
    <MasterTableView AutoGenerateColumns="false" AllowPaging="true" PageSize="5"
     
    PagerStyle-Mode="NextPrevNumericAndAdvanced"   > 
                 

    CS:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
     
            if (e.Item is GridPagerItem) 
            { 
                GridPagerItem pager = (GridPagerItem)e.Item; 
               
                Panel pagerPanel = (Panel)pager.PagerContentCell.FindControl("ctl00"); 
                for (int i = 0; i <= pagerPanel.Controls.Count; i++) 
                { 
                    string strCurrentPage = Convert.ToString(RadGrid1.CurrentPageIndex + 1); 
                    if (pagerPanel.Controls[i].ToString()== "System.Web.UI.WebControls.Label"
                    { 
                        Label lblPage = (Label)pagerPanel.Controls[i]; 
                        if (lblPage.Text == strCurrentPage) 
                        { 
                            lblPage.BackColor = System.Drawing.Color.Red; 
                            break
                        } 
                    } 
                } 
            } 
       } 


    Regards
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 08 Nov 2013 Link to this post

    Hi

    In RadGrid, when i click on pageIndex 4 first time . it show CurrentpagesIndex 0.

            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    int CurrentPageIndex = 0;
                    if (Session["EmployerCurrentPageIndex"] != null)
                    {
                        int.TryParse(Convert.ToString(Session["EmployerCurrentPageIndex"]), out CurrentPageIndex);
                    }
                    EmployerLinkGrid1.CurrentPageIndex = CurrentPageIndex;

                    BindGrid();
                }
            }


     string strCurrentPageIndex = EmployerLinkGrid1.MasterTableView.CurrentPageIndex.ToString();

    protected void EmployerLinkGrid1_ItemCommand(object sender, GridCommandEventArgs e)
     {
        Session["EmployerCurrentPageIndex"] = EmployerLinkGrid1.CurrentPageIndex;
    }

    I check it many way, when click on PagesIndex 4 , it should not show 0. everytime it show previous value.
    When click on pageIndex 4, it show 0
    then click on pageIndex 1, it show 3
    Its really confusing.

    Thanks,
    Muhammad Waseem
    the Telerik Team
  5. <span>w</span>
    <span>w</span> avatar
    84 posts
    Member since:
    Jun 2012

    Posted 08 Nov 2013 Link to this post

    My goodness, i achieve my desired result by using OnPageIndexChanged.

    OnPageIndexChanged="EmployerLinkGrid1_PageIndexChanged"


            protected void EmployerLinkGrid1_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs e)
            {
                string str = e.NewPageIndex.ToString();
            } 

    Thanks,
    Muhammad Waseem
    the Telerik team


  6. Rolland
    Rolland avatar
    6 posts
    Member since:
    Sep 2016

    Posted 17 Oct in reply to w Link to this post

    Sweet exactly what I was searching for,

    Works like a charm.

    Thanks 

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017