
im using rad rotator for rotating latest 10 images from a folder, but the image names are in database.
So ,i have to retrieve those latest 10 image names and should attach these names to images path using image url
like this:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="120px" Width="300px">
<telerik:RadRotator ID="RadRotator1" runat="server" Height="120px" Width="680px" ScrollDirection="Right"
ItemWidth="120px" ItemHeight="100px" BorderColor="Transparent">
<ItemTemplate>
<div style="margin:5px">
<asp:Image ID="image1" runat="server" CssClass="image" ImageAlign="left" ImageUrl="~/images/movies/'<%#Bind("imagename")%>'"/>
</div>
</ItemTemplate>
</telerik:RadRotator>
</telerik:RadAjaxPanel>
pls help me out of this issue
5 Answers, 1 is accepted
Please, note that the problem you report is not directly related to RadControls but to general ASP.NET knowledge. The issue comes from the fact that you cannot bind the url for the image as you have done and you can reproduce the problem with another standard databound control as an asp repeater.
The correct way to bind the url is as shown below:
<
ItemTemplate
>
<
div
style
=
"margin: 5px"
>
<
asp:Image
ID
=
"image1"
runat
=
"server"
CssClass
=
"image"
ImageAlign
=
"left"
ImageUrl='<%#Bind("~/images/movies/{0}", "imagename")%>' />
</
div
>
</
ItemTemplate
>
All the best,
Svetlina
the Telerik team

Thank you very much for responding so early
Its working but the images in rotator are not displayed.Here i should get latest 10 images from folder into rotator by using their names which are in database
I used this code like you said before
this is aspx file
<
div
id
=
"right"
>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
Height
=
"120px"
Width
=
"300px"
>
<
telerik:RadRotator
ID
=
"RadRotator1"
runat
=
"server"
Height
=
"120px"
Width
=
"680px"
ScrollDirection
=
"Right"
ItemWidth
=
"120px"
ItemHeight
=
"100px"
BorderColor
=
"Transparent"
>
<
ItemTemplate
>
<
div
style
=
"margin:5px"
>
<
asp:Image
ID
=
"image1"
runat
=
"server"
CssClass
=
"image"
ImageAlign
=
"left"
ImageUrl='<%#Bind ("~/images/movies/{0}", "imagename") %>'/>
</
div
>
</
ItemTemplate
>
</
telerik:RadRotator
>
</
telerik:RadAjaxPanel
>
</
div
>
this is aspx.cs file
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
SqlDataAdapter da = new SqlDataAdapter("select top 10 imagename from movie order by mid desc",conn);
DataSet ds = new DataSet();
da.Fill(ds,"movie");
RadRotator1.DataSource=ds.Tables["movie"];
RadRotator1.DataBind();
help me out of this
Please, note that your question considers general asp.net knowledge and it is not directly related to RadControls.
Please, modify the code in the following manner:
1) Make sure the path is correct
2) Add the extension of the file as well - e.g .jpg
3) Switch the places of path and evaluated value
If the path is correct and the file is let's say .jpg, you should modify your code in a similar manner as shown below:
<
asp:Image
ID
=
"image1"
runat
=
"server"
CssClass
=
"image"
ImageAlign
=
"left"
ImageUrl='<%#Bind ("ProductID", "~/images/movies/{0}.jpg" %>' />
Sincerely yours,
Svetlina
the Telerik team

Thanks for responding to my thread. I got issue solved in two ways. one way is your replied post and other way i did is below , before to that i have another doubt.
I'm using rad rotator ,I put latest top 10 images in rotator by getting their names from database where images are stored in a folder.
here is code for above procedure
<
telerik:RadRotator
ID
=
"RadRotator1"
runat
=
"server"
Height
=
"120px"
Width
=
"680px"
ScrollDuration
=
"500"
ScrollDirection
=
"Right"
FrameDuration
=
"1500"
ItemWidth
=
"120px"
ItemHeight
=
"100px"
RotatorType
=
"AutomaticAdvance"
DataSourceID
=
"SqlDataSource1"
>
<
ItemTemplate
>
<
asp:Image
ID
=
"image1"
runat
=
"server"
CssClass
=
"image"
ImageAlign
=
"left"
Visible
=
"true"
ImageUrl='<%# String.Format("~/upload data/movies/{0}", DataBinder.Eval(Container.DataItem, "imagename")) %>' />
</
ItemTemplate
>
</
telerik:RadRotator
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:cinema mistakesConnectionString %>"
SelectCommand="SELECT TOP 10 [imagename] FROM [movie] ORDER BY [mid] DESC"></
asp:SqlDataSource
>
Now , when a user click on rotating image then it should redirect to new page where some details of that image are displayed. Please tell me that "on clicking a rotating item it should redirect to new page along by passing image name as id and by using that id, I Can retrieve the details belonging to id from database".
Tell me how to pass an id on item click from that page to other page.
yours Sincerely,
sarat
You can handle the OnClientItemClicked event and redirect from there. As to the parameter, you can simply provide it as a query string parameter.
I want to once again point that this is standard ASP.NET knowledge and if you are not sure how to do this with the rotator, please implement the same with a standard asp repeater control (you can use a button with OnClientClick event to mimic the rotator's OnClientItemClicked event). Once you have implemented this you should use the same logic with the rotator and it will start working with it as well.
If your repeater demo works but you cannot make the things work with RadRotator, please share fully runnable code for the repeater and we will make it work in the same manner with the rotator.
Svetlina
the Telerik team