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

Change label text of pager item

5 Answers 398 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 30 Jul 2008, 10:24 PM
I found example code of how to change the label text for the advanced items in the pager.  Would the same code work to change the "Change Page" text  and the "Displaying Page" text on the standard pager?  And what would be the name of those labels?

protected void RadGrid_Subs_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        if (e.Item is GridPagerItem)  
        {  
            Label changePageLabel = (Label)e.Item.FindControl("GoToPageLabel");  
            changePageLabel.Visible = false;  
        }  
    } 

Thanks.

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 31 Jul 2008, 06:06 AM
Hi Angie,

Try the following code snippet and see whether it is working.

CS:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridPagerItem) 
        { 
            GridPagerItem pager = (GridPagerItem)e.Item; 
            pager.FindControl("ctl00").Visible = false
           
        } 
    } 


Thanks
Shinu.
0
Angie
Top achievements
Rank 1
answered on 31 Jul 2008, 05:14 PM
Hi Shinu, thanks for replying.  Oddly, though the controls are there, the FindControl returns null with "ct100" and pretty much anything else I try, even though I can see the controls in the Immediate window.

So, here's what I ended up having to do, which makes me nervous, as this could probably be easily broken if anything changes:

if (e.Item is GridPagerItem)  
{  
    GridPagerItem pi = (GridPagerItem)e.Item;  
    LiteralControl lit = (System.Web.UI.LiteralControl)pi.Controls[0].Controls[0].Controls[0];  
    lit.Text = "Page:";  
 

Any other suggestions?  Is there an "official" way to do this?

Thanks.
0
Daniel
Telerik team
answered on 01 Aug 2008, 04:45 AM
Hello Angie,

Please try the following snippet:
RadGrid1.MasterTableView.PagerStyle.PagerTextFormat = "CP: {4}  |  DP {0} of {1}, items {2} to {3} of {5}"


Kind Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Angie
Top achievements
Rank 1
answered on 01 Aug 2008, 03:53 PM
That works perfectly!  Thanks.

Actually, related to that, is there a property I can set to show a link to the first and last pages?  Without using a template?  Thanks!
0
Daniel
Telerik team
answered on 04 Aug 2008, 05:18 PM
Hi Angie,

Generally, the recommended way is to use a PagerTemplate. The demo - PagerTemplate - is illustrating the needed approach. Otherwise, you can examine Programmatic pager customization in order to find out how to replace the built-in pager with your own. However it is easier to use a template.

Greetings,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Angie
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Angie
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or