This is a migrated thread and some comments may be shown as answers.

How to Current Selected page of RadGrid

6 Answers 640 Views
Grid
This is a migrated thread and some comments may be shown as answers.
CHETAN JAITLY
Top achievements
Rank 1
CHETAN JAITLY asked on 17 Feb 2009, 11:18 AM
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

6 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Feb 2009, 06:14 AM
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
0
Waseem
Top achievements
Rank 1
answered on 08 Nov 2013, 08:26 PM
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
0
Waseem
Top achievements
Rank 1
answered on 08 Nov 2013, 09:40 PM
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


0
Rolland
Top achievements
Rank 1
answered on 17 Oct 2016, 05:37 PM

Sweet exactly what I was searching for,

Works like a charm.

Thanks 

0
sergio
Top achievements
Rank 1
answered on 27 Feb 2020, 05:55 PM
We have to do all this just to get a simple page number ? It´s better program my own UI. 
0
Rumen
Telerik team
answered on 09 Apr 2020, 09:08 AM

Hi Sergio,

Thank you for the valuable feedback we received from you via email and here at the Telerik forums! It is much appreciated!

If the Telerik UI for ASP.NET AJAX suite does not match your requirements for solely C# development, you might be interested in to check our other offerings which are entirely C# based:

If you have any questions, please open a support ticket or open a new forum thread and we will be glad to provide the needed information and to assist you.

Regards,
Rumen
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
CHETAN JAITLY
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Waseem
Top achievements
Rank 1
Rolland
Top achievements
Rank 1
sergio
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or