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

Changing datasource parameters causes RadRotator to stop rotating

1 Answer 62 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Trent Wheeler
Top achievements
Rank 1
Trent Wheeler asked on 21 Aug 2010, 09:07 AM
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
            thumbRotator.DataBind()
        End If
    End Sub
  
End Class

<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="thumbRotator">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="imagePreview" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <table>
        <tr>
            <td colspan="3">
                <asp:DataList ID="DataList1" runat="server" DataSourceID="ObjectDataSource1" 
                    DataKeyField="GalleryID" RepeatColumns="5">
                    <ItemTemplate>
                        <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") %>' />
                    </ItemTemplate>
                </asp:DataList>
                <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
                    SelectMethod="GetGalleriesByParent" TypeName="GalleryManager" >
                    <SelectParameters>
                        <asp:Parameter DefaultValue="0" Name="GalleryID" Type="Int32" />
                        <asp:Parameter Name="ShowParentGallery" Type="Boolean" DefaultValue="True" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
        </tr>
        <tr>
            <td>
                <img src="gallery_scroll_left.png" id="gallery_scroll_left" />
            </td>
            <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">
                    <ItemTemplate>
                        <div class="itemTemplate">
                            <img src='<%# DataBinder.Eval(Container.DataItem, "ImageUrl", "thumbs/{0}") %>' runat="server" id="thumbImage" />
                        </div>
                    </ItemTemplate>
                    <ControlButtons LeftButtonID="gallery_scroll_left" RightButtonID="gallery_scroll_right" />
                </telerik:RadRotator>
                <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" SelectMethod="GetImagesByGallery" TypeName="GalleryManager">
                    <SelectParameters>
                        <asp:Parameter DefaultValue="0" Name="GalleryID" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </td>
            <td>
                <img src="gallery_scroll_right.png" id="gallery_scroll_right" />
            </td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: center;">
                <asp:Image ID="imagePreview" runat="server" ImageUrl="no-image.png" />
            </td>
        </tr>
    </table>
    </form>
</body>

1 Answer, 1 is accepted

Sort by
0
Accepted
Fiko
Telerik team
answered on 25 Aug 2010, 04:38 PM
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,
Fiko
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
Tags
Rotator
Asked by
Trent Wheeler
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Share this question
or