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

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

1 Answer 44 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Antoine
Top achievements
Rank 1
Antoine asked on 23 Aug 2012, 08:14 AM
Hello,

 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);
}
aspx:

                <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"
                       onclick="btn_Click">
        <Icon PrimaryIconUrl ="~/Images/FIT_Ajout_BOITE_ON_Small.png" PrimaryIconLeft="2px" PrimaryIconTop="2px"  PrimaryIconHeight="25px"  PrimaryIconWidth="35px"/>
                    
    </telerik:RadButton>

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

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

thank you

1 Answer, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 27 Aug 2012, 12:37 PM
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.

Greetings,
Slav
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.
Tags
Rotator
Asked by
Antoine
Top achievements
Rank 1
Answers by
Slav
Telerik team
Share this question
or