Changing datasource parameters causes RadRotator to stop rotating

2 posts, 1 answers
  1. Trent Wheeler
    Trent Wheeler avatar
    5 posts
    Member since:
    Mar 2006

    Posted 21 Aug 2010 Link to this post

    I'm tryng to create an Image Gallery that uses a datalist to drill down through the subgallery structure, and at each level there is a RadRotator that should display the images in the current subgallery.  The problem is that when I add the logic that changes the datasource parameter that controls which subgallery's images are being displayed, it stops the RadRotator from rotating.

    See code below:

    Imports System.IO
    Partial Class test
        Inherits System.Web.UI.Page
        Protected Sub thumbRotator_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles thumbRotator.DataBound
            If thumbRotator.Items.Count < 4 Then
                thumbRotator.RotatorType = Telerik.Web.UI.RotatorType.FromCode
            End If
        End Sub
        Protected Sub thumbRotator_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadRotatorEventArgs) Handles thumbRotator.ItemClick
            Dim thumbUrl As String = CType(e.Item.FindControl("thumbImage"), HtmlImage).Src
            Dim previewUrl As String = "~/App_Content/gallery/" & Path.GetFileName(thumbUrl)
            imagePreview.ImageUrl = previewUrl
        End Sub
        Protected Sub DataList1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles DataList1.ItemCommand
            If e.CommandName = "Gallery" Then
                ObjectDataSource1.SelectParameters("GalleryID").DefaultValue = e.CommandArgument
                ObjectDataSource2.SelectParameters("GalleryID").DefaultValue = e.CommandArgument
            End If
        End Sub
    End Class

        <form id="form1" runat="server">
        <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
        <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
                <telerik:AjaxSetting AjaxControlID="thumbRotator">
                        <telerik:AjaxUpdatedControl ControlID="imagePreview" />
                <td colspan="3">
                    <asp:DataList ID="DataList1" runat="server" DataSourceID="ObjectDataSource1" 
                        DataKeyField="GalleryID" RepeatColumns="5">
                            <img src='<%# DataBinder.Eval(Container.DataItem, "ImageID", "thumbs/{0}") %>' runat="server" id="thumbImage" /><br />
                            <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("Title") %>' CommandName="Gallery" CommandArgument='<%# Eval("GalleryID") %>' />
                    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                        SelectMethod="GetGalleriesByParent" TypeName="GalleryManager" >
                            <asp:Parameter DefaultValue="0" Name="GalleryID" Type="Int32" />
                            <asp:Parameter Name="ShowParentGallery" Type="Boolean" DefaultValue="True" />
                    <img src="gallery_scroll_left.png" id="gallery_scroll_left" />
                <td style="vertical-align:middle; height: 140px;">
                    <telerik:RadRotator ID="thumbRotator" runat="server" RotatorType="ButtonsOver" 
                            Width="572" Height="118px" ItemHeight="118" ItemWidth="145" FrameDuration="1" 
                            ScrollDirection="Left,Right" DataSourceID="ObjectDataSource2">
                            <div class="itemTemplate">
                                <img src='<%# DataBinder.Eval(Container.DataItem, "ImageUrl", "thumbs/{0}") %>' runat="server" id="thumbImage" />
                        <ControlButtons LeftButtonID="gallery_scroll_left" RightButtonID="gallery_scroll_right" />
                    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetImagesByGallery" TypeName="GalleryManager">
                            <asp:Parameter DefaultValue="0" Name="GalleryID" Type="Int32" />
                    <img src="gallery_scroll_right.png" id="gallery_scroll_right" />
                <td colspan="3" style="text-align: center;">
                    <asp:Image ID="imagePreview" runat="server" ImageUrl="no-image.png" />
  2. Answer
    Fiko avatar
    1406 posts

    Posted 25 Aug 2010 Link to this post

    Hello Trent,

    I see that you change the type of the RadRotator control when the its items' count is < 4. Could you please check whether this condition is true when you change the datasource of the control? If so, then the behavior that you experience is expected, because in RotatorType="FromCode" mode you need to write your custom code that will move the RadRotator's items (using its client-side API).

    in case that the suggested does not help, could you please send me a runnable project which shows the problem? I ask you this because I was not able to reproduce the problem using the provided code.

    All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top