how can we add items (image) in my rotator by clicking on the button

2 posts, 0 answers
  1. Antoine
    Antoine avatar
    4 posts
    Member since:
    Apr 2012

    Posted 23 Aug 2012 Link to this post


     I have a button on my page, TexBox that will contain the name of a person and empty rotator at the beginning, how can we add items (image) in my rotator by clicking on the button, I have been the following code in the button's onclick:
    C# :
      protected void btn_Click (object sender, EventArgs e)
    System.Web.UI.WebControls.Image Image image = new ();
    image.ImageUrl = "~ / Images / Customers /" + + TextBoxmember.Text. "jpg"};
    RadRotatorItem item = new RadRotatorItem ();
    item.Controls.Add (image);
    RadRotator1.Items.Add (item);

                    <asp:TextBox ID="TextBoxmember"  Width="245px"    CssClass="inputTextEntryAutocomp" TabIndex="2"  runat="server"></asp:TextBox>

    <telerik:RadButton ID="btnIcon" runat="server"  Height="30px" Width="150px" Skin="Windows7"
                           Text="Add member"
            <Icon PrimaryIconUrl ="~/Images/FIT_Ajout_BOITE_ON_Small.png" PrimaryIconLeft="2px" PrimaryIconTop="2px"  PrimaryIconHeight="25px"  PrimaryIconWidth="35px"/>

        <telerik:RadRotator ID="RadRotator1" runat="server"
                            CssClass="verticalRotator"  Height="250px"  ScrollDuration="500" FrameDuration="2000"  
                            RotatorType = "Buttons">
            <ItemTemplate    >

      the problem is that it always loads the last person on entry and not save the old values.

    thank you
  2. Slav
    Slav avatar
    1351 posts

    Posted 27 Aug 2012 Link to this post

    Hello Antoine,

    I would suggest the following approach:

    1. Adding the new item in a collection that implements the IEnumerable interface, for example a List, when new data is entered in the TextBox.
    2. After the item is inserted, pass the collection to the DataSource property of the control and call DataBind() to rebind the rotator.
    The client-side API of RadRotator includes methods for adding and removing items so your can consider using it in your scenario. This online demo show them in action.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top