Accessing Radrotator Items

4 posts, 1 answers
  1. Fusion Outsourcing Software Pvt. Ltd.
    Fusion Outsourcing Software Pvt. Ltd. avatar
    16 posts
    Member since:
    Apr 2009

    Posted 04 Jun 2009 Link to this post

    Hello Telerik Team,

    I have a Radrotator containing Images. Images are stored in database. So radrotator is bounded to database. on clicking the images i want to access the ID of the image clicked, from database.

    We tried a way that binding tooltip text for that image as the name of the image stored in datasource. 
    But when we go in Click event of rotator, it shows tooltip text as empty string. This is because we bind tooltip at run time. We also tried e.item.index but it returns the index of Image in the rotator but  we want the ID that it has in database.

    It would be great if you can provide us with some sample application that has binding rotator with database on page load & later "Onitemclick" we can access the ID or name of that image that it has in database.

    Please Help us with this.

    Shoqeen Ahmed.

  2. Answer
    Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 08 Jun 2009 Link to this post

    Hi,

    You can use a hidden field in the RadRotator's template and store the images ID in it. As an alternative you can add your custom property to the image object and bind its value to the ID field. Then you can get reference to the controls inside the ItemClick handler as follow :
    public void RadRotator1_ItemClick(object sender, RadRotatorEventArgs e) 
        Image img = e.Item.FindControl("Image1"as Image; 

    For your convenience I have implemented the second approach in a demo and attach it to the thread.

    I hope this helps.

    Sincerely yours,
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Peter Ivanov
    Peter Ivanov avatar
    6 posts
    Member since:
    Oct 2009

    Posted 19 Nov 2009 Link to this post

    Hi Fiko,

    I would like to do something similar to what you've demonstrated above. I would like to record hits on images in a RadRotator. I'll be recording the hits in a database, so I'll need the ID of the image clicked on. What I would usually do is add a command argument to an asp hyperlink and then listen for it in my code, but in the rotator I can't add a command name or argument to a hyperlink. And how do I get that ID in my VB.

    I've included my ASP code to assist you in seeing my problem.

    <telerik:RadRotator runat="server" ID="RadRotator2" RotatorType="AutomaticAdvance" ScrollDirection="Up" FrameDuration="7000" DataSourceID="dsRotator""> 
        <ItemTemplate> 
            <asp:HyperLink ID="imgImage" runat="server" ImageUrl='<%# "~/Images/Home/" & Eval("DBSrc") %>' NavigateUrl='<%# Eval("DBUrl") %>' /> 
        </ItemTemplate> 
    </telerik:RadRotator> 
  5. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 23 Nov 2009 Link to this post

    Hello Peter,

    In this case you need to use the ItemCreated server event of the RadRotator control and attach a handler to the LinkButton control (HyperLink does not have click event). For your convenience I have attached a fully working demo to the thread.

    I hope this helps.

    Best wishes,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top