Pager in RadGrid

4 posts, 0 answers
  1. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 08 Apr 2011 Link to this post

    I have a RadGrid with Pager Template. The pager contains 4 asp buttons for next, previous, last and first functions also we have RadComboBox to set the pagesize, a RadNumeric TextBox for Current page index. The Pager template is defined in aspx page. My problem is i can't get this controls in server side ( in C# ). How can i get this pager template controls in  RadGrid from Server Side(C#).
    also how can i handle the events of this pager template controls  from server side.
  2. Pavlina
    Pavlina avatar
    6070 posts

    Posted 08 Apr 2011 Link to this post

    Hello Velkumar,

    You can wire ItemCreated event of RadGrid, check if e.Item is GridPagerItem and find the needed controls in pager template.

    For more information about how to achieve the desired functionality, you can refer to the online resources below:

    Kind regards,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. Velkumar
    Velkumar avatar
    85 posts
    Member since:
    Apr 2011

    Posted 09 Apr 2011 Link to this post

    Hello Pavlina ,

               I am using the following code in RadGrid to Create pager Template.

    <telerik:RadGrid runat="server"   AllowMultiRowSelection="false" ID="radGridTaxRate" Font-Names="Verdana"  Skin="Marzar" EnableEmbeddedSkins="false" AutoGenerateColumns="False">
                        <ClientSettings   EnablePostBackOnRowClick="false"     >
                            <Selecting AllowRowSelect="True"   />  
                        <MasterTableView AllowPaging="true"   >
                            <asp:Panel ID="PagerPanel" Style="padding: 6px" runat="server">
                                <div style="float: left">
                                    <span style="margin-top: 2px; float: left; margin-right: 3px;font-size:8pt;">Page size:</span>
                                    <telerik:RadComboBox Skin="Office2007" ID="RadComboBox1" DataSource="<%# new object[]{10, 20, 30, 40, 50} %>"
                                        Style="margin-top: 2px;float: left; vertical-align: baseline; margin-right: 20px; text-align:center; height:25px"
                                        Width="40px" SelectedValue='<%# DataBinder.Eval(Container, "Paging.PageSize") %>'
                                        runat="server" OnClientSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"   CssClass="CustomCssClass"  >
                               <div style="margin: 0px; float: right;"></div>                                                                                                                                                                                           
                               <div style="margin: 0px; padding: 0px; float: left; margin-right: 10px; white-space: nowrap;">
                                    <asp:Button ID="Button1" runat="server" OnClientClick="changePage('first'); return false;"
                                        CommandName="Page" CommandArgument="First" CssClass="PagerButton FirstPage" />
                                    <asp:Button ID="Button2" runat="server" OnClientClick="changePage('prev'); return false;"
                                        CommandName="Page" CommandArgument="Prev" CssClass="PagerButton PrevPage" />
                                    <span style="vertical-align: middle;font-size:8pt;">Page:</span>
                                    <telerik:RadNumericTextBox ID="RadNumericTextBox1" Skin="Office2007" Width="25px" Font-Size="8pt"
                                        Value='<%# (int)DataBinder.Eval(Container, "Paging.CurrentPageIndex") + 1 %>'
                                        runat="server" EnabledStyle-HorizontalAlign="Center"  >
                                        <ClientEvents OnValueChanged="RadNumericTextBox1_ValueChanged"     />
                                        <NumberFormat DecimalDigits="0" />
                                    <span style="vertical-align: middle;font-size:8pt;">of
                                        <%# DataBinder.Eval(Container, "Paging.PageCount")%>
                                    <asp:Button ID="Button3" runat="server" OnClientClick="changePage('next'); return false;"
                                        CommandName="Page" CommandArgument="Next" CssClass="PagerButton NextPage" />
                                    <asp:Button ID="Button4" runat="server" OnClientClick="changePage('last'); return false;"
                                        CommandName="Page" CommandArgument="Last" CssClass="PagerButton LastPage" />                                                                                                      
                               <asp:Panel runat="server" ID="NumericPagerPlaceHolder"/>                                                                                                                                                                                                                   
                    </MasterTableView >

    In this i have buttons, checkbox, and combobox. Can i create object for this items (for asp button --->  Button Button1, for RadNumerictextBox   RadNumericTextbox1....etc). also i have a problem that is unable to receive or handle the events such as click for button , textchanged for RadNumerictextBox from server side(C#).
    protected Button Button1;
       Button1.Click += new EventHandler(Button1_Click);   
    void Button1_Click(object sender, EventArgs e)

    Button1 is present inside Pagertemplate. While clicking this function will not call. this problem will also arise for RadNumericTextBox,
    RadComboBox,  . please give the solution for this problems.

  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Apr 2011 Link to this post


    Give a try this code. Hope this might help you.

    protected void radGridTaxRate_ItemCreated(object sender, GridItemEventArgs e)
           if (e.Item is GridPagerItem)
               GridPagerItem pagerItem = (GridPagerItem)e.Item;
               Button btn1 = (Button)pagerItem.FindControl("Button1");
               btn1.Click += new EventHandler(btn1_Click);
       void btn1_Click(object sender, EventArgs e)

    With regards,
Back to Top