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

How to bind RadRotator to List<t>

8 Answers 180 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Flea#
Top achievements
Rank 1
Flea# asked on 04 May 2009, 03:03 AM
Hello,

I have a List<string> collection and I was wondering if it was possible to bind the rad rotator to this list collectiong? What I have currently does not work; I can't get any data to show up.

Here is what I have for the aspx page:

            <telerik:RadRotator ID="catholicFactRotator" runat="server" RotatorType="AutomaticAdvance"  
            FrameDuration="3000" ScrollDirection="Up" > 
            </telerik:RadRotator>  

Here is what I have for my code behind:

    protected void Page_Load(object sender, EventArgs e) 
    { 
        Data data = new Data(); 
 
        this.radrotator1.DataSource = data.GetListofStrings(); 
        this.radrotator1.DataBind(); 
    } 

I don't receive any errors on the page, but nothing shows up. I appreciate any help!

Thanks,
Flea#

8 Answers, 1 is accepted

Sort by
0
Accepted
Fiko
Telerik team
answered on 05 May 2009, 07:48 AM
Hi Flea#,

You can bind the RadRotator control to a List<string> object, but you need to define an ItemTemplate in order to achieve the desired result. For example :
  • The codebehind :
    protected void Page_Load(object sender, EventArgs e) 
        List<string> list = new List<string>() { "Item 1""Item 2""Item 3" }; 
        RadRotator1.DataSource = list; 
        RadRotator1.DataBind(); 
  • Declare a RadRotator control with an ItemTemplate  on the ASPX page :
    <telerik:RadRotator ID="RadRotator1" runat="server" Width="100" ItemWidth="100" Height="110" 
        ItemHeight="110"
        <ItemTemplate> 
            <div> 
                <%# Container.DataItem %> 
            </div> 
        </ItemTemplate> 
    </telerik:RadRotator> 

This setup will work in your scenario. I hope this helps.


Regards,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Flea#
Top achievements
Rank 1
answered on 05 May 2009, 10:08 PM
Thanks Fiko, that fixed it right up! I appreciate your help!

-Flea#
0
Cristian
Top achievements
Rank 1
answered on 27 Jun 2012, 03:55 PM
Hi, I'm trying to bind the in code behind a radrotator with image buttons.
Fiko's example seems to be the solution but what should I put in ItemTemplate in order to make visible the buttons?

Hope your help.
0
Princy
Top achievements
Rank 1
answered on 18 Sep 2012, 08:52 AM
Hi Cristian,

I suppose you want to bind the ImageButton into the ItemTemplate of RadRotator. Try the following code.

ASPX:
<telerik:RadRotator ID="RadRotator1" runat="server" Width="100" ItemWidth="100" Height="110" RotatorType="Buttons" ItemHeight="110">
  <ItemTemplate>
     <div>
        <asp:ImageButton ID="btn" runat="server" ImageUrl="<%# Container.DataItem %>" />
     </div>
  </ItemTemplate>
</telerik:RadRotator>

C#:
protected void Page_Load(object sender, EventArgs e)
    {
        List<string> list = new List<string>() { "~/Images/image1.jpg", "~/Images/image2.jpg", "~/Images/image3.jpg" };
        RadRotator1.DataSource = list;
        RadRotator1.DataBind();
    }

Please elaborate your scenario if it doesn't helps.

Regards,
Princy.
0
Bhavya
Top achievements
Rank 1
answered on 10 Feb 2016, 07:32 AM

hi Princy,

i created charts as usercontrols

i have to add user control objects to radrotator in code behind.

how i can do that?

help me out from this..

thanks in advance!

 

0
Bhavya
Top achievements
Rank 1
answered on 10 Feb 2016, 02:32 PM
No thanks :)
i worked on it ! and i did it :)
0
RJ
Top achievements
Rank 1
answered on 15 Sep 2016, 08:06 PM

Hi Manu,

Can you share your codes, my requirements is same like yours.

Thanks in advance!

0
RJ
Top achievements
Rank 1
answered on 24 Nov 2016, 11:06 AM

No Thanks!

bootstrap carousel does the job.

Tags
Rotator
Asked by
Flea#
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Flea#
Top achievements
Rank 1
Cristian
Top achievements
Rank 1
Princy
Top achievements
Rank 1
Bhavya
Top achievements
Rank 1
RJ
Top achievements
Rank 1
Share this question
or