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

Accessing Radrotator Items

3 Answers 328 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Fusion Outsourcing Software Pvt. Ltd.
Top achievements
Rank 1
Fusion Outsourcing Software Pvt. Ltd. asked on 04 Jun 2009, 03:47 PM

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.

3 Answers, 1 is accepted

Sort by
0
Accepted
Fiko
Telerik team
answered on 08 Jun 2009, 02:54 PM
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.
0
Peter Ivanov
Top achievements
Rank 2
answered on 19 Nov 2009, 09:44 AM

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> 
0
Fiko
Telerik team
answered on 23 Nov 2009, 09:49 AM
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.
Tags
Rotator
Asked by
Fusion Outsourcing Software Pvt. Ltd.
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Peter Ivanov
Top achievements
Rank 2
Share this question
or