A Simple Question For DataPager

4 posts, 0 answers
  1. gzzn
    gzzn avatar
    12 posts
    Member since:
    Jan 2011

    Posted 18 May 2011 Link to this post

    <telerik:RadDataPagerTemplatePageField
        <PagerTemplate
            <asp:DropDownList ID="DropDownList1" runat="server"
            </asp:DropDownList
            <asp:Label ID="lblTimeAmount" runat="server" Text="..." ></asp:Label
        </PagerTemplate
    </telerik:RadDataPagerTemplatePageField>
    protected void Page_Load(object sender, EventArgs e)  
    {
       //How to Get or Set Control's Value to Any in DropDownList1 or lblTimeAmount
      
    }
    also:
    <telerik:RadToolBarButton runat="server" Text="SearchBox"
         <ItemTemplate
             <telerik:RadComboBox ID="RadComboBox1" Runat="server"
                 <Items
                     <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" 
                         Value="RadComboBoxItem1" /> 
                     <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" 
                         Value="RadComboBoxItem2" /> 
                     <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" 
                         Value="RadComboBoxItem3" /> 
                 </Items
             </telerik:RadComboBox
         </ItemTemplate
     </telerik:RadToolBarButton
     <telerik:RadToolBarButton runat="server" Text="SearchCount"
         <ItemTemplate
             <asp:Label ID="lblTimeAmount" runat="server" Text="..." ></asp:Label>
         </ItemTemplate
     </telerik:RadToolBarButton>
    protected void Page_Load(object sender, EventArgs e)   
       //How to Get or Set Control's Value to Any in DropDownList1 or lblTimeAmount
    }
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 23 May 2011 Link to this post

    Hello,

    Here is example based on your code:

    Aspx:
    <telerik:RadDataPager runat="server" ID="RadDataPager1" OnFieldCreated="RadDataPager1_FieldCreated">
      <Fields>
        <telerik:RadDataPagerTemplatePageField>
          <PagerTemplate>
            <asp:DropDownList ID="DropDownList1" runat="server">
            </asp:DropDownList>
            <asp:Label ID="lblTimeAmount" runat="server" Text="..."></asp:Label>
          </PagerTemplate>
        </telerik:RadDataPagerTemplatePageField>
      </Fields>
    </telerik:RadDataPager>

    C#
    protected void Page_Load(object sender, EventArgs e)
    {
        DropDownList ddl = RadDataPager1.Controls[0].FindControl("DropDownList1") as DropDownList;
        ddl.Items.Add(new ListItem("item 0", "item 0"));
    }
     
    protected void RadDataPager1_FieldCreated(object sender, RadDataPagerFieldCreatedEventArgs e)
    {
        DropDownList ddl = e.Item.FindControl("DropDownList1") as DropDownList;
        ddl.Items.Add(new ListItem("item1", "item1"));
        Label label1 = e.Item.FindControl("lblTimeAmount") as Label;
        label1.Text = "changed text";
    }

    Also see this help topic about accessing controls inside RadToolBar's template:
    http://www.telerik.com/help/aspnet-ajax/toolbar-templates-accessing-controls.html

    Greetings,
    Vasil
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. gzzn
    gzzn avatar
    12 posts
    Member since:
    Jan 2011

    Posted 24 May 2011 Link to this post

    protected void Page_Load(object sender, EventArgs e)
    {
        for (int i = 0; i < this.RadDataPager1.Fields.Count; i++)
        {
            switch (this.RadDataPager1.Fields[i].PagerType)
            {
                case "RadDataPagerTemplatePageField":
                    Label label1 = (Label)this.RadDataPager1.Controls[i].FindControl("Label1");
                    label1.Text = "testx ...";
                    DropDownList ddl = (DropDownList)this.RadDataPager1.Controls[i].FindControl("DropDownList1");
                    ddl.Items.Add(new ListItem("item 0", "item 0"));
                    break;
            }
        }
    }
  5. gzzn
    gzzn avatar
    12 posts
    Member since:
    Jan 2011

    Posted 24 May 2011 Link to this post

    protected void RadDataPager1_PreRender(object sender, EventArgs e)
    {
        for (int i = 0; i < this.RadDataPager1.Fields.Count; i++)
        {
            if (this.RadDataPager1.Fields[i] is RadDataPagerTemplatePageField)
            {
                Label labelTimeAmount = (Label)this.RadDataPager1.Controls[i].FindControl("lblTimeAmount");
                labelTimeAmount.Text = iTime.ToString();
            }
        }
    }
Back to Top