RadDataPager findcontrol

2 posts, 0 answers
  1. Noel Tam
    Noel Tam avatar
    2 posts
    Member since:
    Apr 2004

    Posted 02 Jan 2011 Link to this post

    hi all
    I have a list view and RadDataPager . Inside the RadDataPager , I have a dropdownlist control, I would like get the value of the dropdownlist control. I try ctype(RadDataPager.findcontrol("dropdownlist"), dropdownlist).selectedvalue but failed. 

    how can I get the find the control inside the RadDataPager. Thanks

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

    Posted 09 Feb 2011 Link to this post

    Hello Noel,

    Give a try with the following code snippet to get the control inside RadDataPager.
    <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
       .   .    .   .   .   .
                    <div style="float: right">
                            <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" />
                            <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Container.Owner.StartRowIndex+Container.Owner.PageSize %>" />
                            <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                            <br />
                            <br />
                            <asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource1" DataTextField="Fieldname"
                                DataValueField="Fieldname" runat="server">

    protected void Page_Load(object sender, EventArgs e)
            string sortType = null;
            RadDataPager dataPager = (RadDataPager)RadListView1.FindControl("RadDataPager1");
            if (dataPager != null)
                DropDownList ddl = FindControlRecursive(dataPager, "DropDownList1") as DropDownList;
                if (ddl != null)
                    sortType = ddl.SelectedValue;
        public static Control FindControlRecursive(Control Root, string Id)
            if (Root.ID == Id)
                return Root;
            foreach (Control Ctl in Root.Controls)
                Control FoundCtl = FindControlRecursive(Ctl, Id);
                if (FoundCtl != null)
                    return FoundCtl;
            return null;

Back to Top