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

setting PagerTextFormat from codebehind

3 Answers 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angie
Top achievements
Rank 1
Angie asked on 02 Jul 2010, 06:37 PM
I am trying to set the pagertextformat from the codebehind.

I have tried doing so from the Page_Load and also from the NeedDataSource functions, but neither is working.

When I use set the format from the aspx page, it works fine.

Here is the line I am using:

gv.PagerStyle.PagerTextFormat =

"Page:{4} Page {0} of {1}";

 

Is there some other method I need to be using?

Grid code below.  Again, if I just put it inline with the grid declaration, it works fine.

Thanks.

<telerik:RadGrid ID="gv"   
                                        OnNeedDataSource="gv_NeedDataSource" 
                                        OnItemCommand="gv_OnItemCommand" 
                                        AllowMultiRowSelection="true"   
                                        PageSize="50"   
                                        Width="625px"   
                                        Skin="Windows7" 
                                        CssClass="Custom"    
                                        runat="server" > 
 
                                        <ClientSettings> 
                                            <Selecting AllowRowSelect="true" /> 
                                        </ClientSettings> 
                                          
                                        <MasterTableView DataKeyNames="messageID, messageRead" AutoGenerateColumns="False" Width="100%"  AllowSorting="true" AllowPaging="true" AllowCustomPaging="true" TableLayout="Fixed">  
                                          <PagerStyle  Mode="NextPrevAndNumeric"  Position="TopAndBottom" PageButtonCount="5"    /> 
                                            <Columns> 
                                                <telerik:GridClientSelectColumn HeaderStyle-Width="35px" ItemStyle-Width="35px" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"   /> 
                                                                                                 <telerik:GridTemplateColumn  SortExpression="Subject" UniqueName="Subject" EditFormColumnIndex="2">  
                                                    <ItemTemplate> 
                                                        <asp:LinkButton ID="lbMsg" Text='<%#Eval("subject")%>' runat="server" CommandArgument='<%#Eval("messageID")%>' CommandName="msg"/>  
                                                    </ItemTemplate> 
                                                </telerik:GridTemplateColumn> 
 
                                                <telerik:GridTemplateColumn  SortExpression="messageDate" UniqueName="Date" EditFormColumnIndex="3">  
                                                    <ItemTemplate> 
                                                        <%#GetDate(Eval("messageDate"), Eval("messageRead"))%> 
                                                    </ItemTemplate> 
                                                </telerik:GridTemplateColumn> 
 
                                            </Columns> 
                                        </MasterTableView> 
                                    </telerik:RadGrid> 
 

3 Answers, 1 is accepted

Sort by
0
Angie
Top achievements
Rank 1
answered on 02 Jul 2010, 07:38 PM
I am also having a problem setting the Next Page / Previous Page Tooltip from the codebehind.  What am I doing wrong? 

Thank you.
0
Accepted
Princy
Top achievements
Rank 2
answered on 05 Jul 2010, 08:12 AM
Hello Angie,

I tried the following code snippet in PageLoad event to set the PagerTextFormat and to change the Next Page / Previous Page Tooltip  from code behind and I got it working.  

C#:
 
 protected void Page_Load(object sender, EventArgs e) 
    { 
        RadGrid1.MasterTableView.PagerStyle.Mode = GridPagerMode.NextPrev; 
        RadGrid1.MasterTableView.PagerStyle.PagerTextFormat = "The Page:{4} My Page {0} of {1}"
        RadGrid1.MasterTableView.PagerStyle.PrevPageToolTip = "new ToolTip"// set new ToolTip 
        RadGrid1.MasterTableView.PagerStyle.NextPageToolTip = "new ToolTip"
     } 

I am using telerik version 2010, 1, 519, 35. Which version of RadControls are you using?

Thanks,
Princy.
0
Angie
Top achievements
Rank 1
answered on 07 Jul 2010, 04:14 PM
Thanks Princy!  I was missing the MasterTableView part.  It works now!  :-)
Tags
Grid
Asked by
Angie
Top achievements
Rank 1
Answers by
Angie
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or