Rebind RadRotator

2 posts, 0 answers
  1. Prateek
    Prateek avatar
    2 posts
    Member since:
    Sep 2012

    Posted 18 Apr 2013 Link to this post


    I am using a RadRotator in Sitefinity. I have bound images to it on PageLoad. It works fine. Now I want to rebind the control on filtering by category. When I click the category the DataSource is new, but it doesn't do anything to the images. It still shows the original set.

    This is how I bind:

    VideosCarousel.DataSource = GetVideos("All");

    And to rebind I do this:

    VideosCarousel.DataSource = null;
    VideosCarousel.DataSource = GetVideos("Business");

    The categories are "a" links. Like this:

    <li><a id="all" onclick="GetAllVideos(this)">All</a></li>
     <li><a id="buss" onclick="GetFilteredVideos(this)">Business</a></li>
    <li><a id="cnh" onclick="GetFilteredVideos(this)">Community&Health</a></li>
    <li><a id="tech" onclick="GetFilteredVideos(this)">Technology</a></li>
  2. Slav
    Slav avatar
    1359 posts

    Posted 23 Apr 2013 Link to this post

    Hello Prateek,

    It is not required to set a null datasource for the RadRotator in order to rebind it. All you need to do is perform a full or partial postback (in this case you should ensure that the rotator is updated by the AJAX request), set a different datasource and invoke the DataBind method of the rotator. You can check this in the code sample below:

    <telerik:RadRotator ID="RadRotator1" runat="server" FrameDuration="3000" RotatorType="Buttons"
        Height="113px" ItemHeight="113px" Width="190px" ItemWidth="150px"
            <img src="<%# ResolveUrl("images/" + Container.DataItem) %>" alt="" />
    <asp:Button Text="Rebind rotator" runat="server" />

    protected void Page_Load(object sender, EventArgs e)
        if (!IsPostBack)
            RadRotator1.DataSource = new[] { "barcelona.jpg", "london.jpg", "paris.jpg" };
            RadRotator1.DataSource = new[] { "dubrovnik.jpg", "luxembourg.jpg", "piza.jpg" };

    All the best,
    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.
Back to Top