Repeater and Index Value

S

Stan SR

Hi,

I use a repeater that displays images.
I need to add dynamically a jscript function on each image that use the
index value of the repeater

<asp:Repeater ID="ph" runat="server" DataSourceID="myDataSource">
<ItemTemplate>
<asp:HyperLink runat="server" ID="link"
NavigateUrl="javascript:Slides(INDEXREPEATER)">
<asp:Image runat="server" ID="img" ImageUrl='<%#
Eval("myPic") %>' />
</ItemTemplate>
</asp:Repeater>

How to replace the INDEXREPEATER by the current index ?

Thanks in advance

Stan
 
R

Riki

Stan said:
Hi,

I use a repeater that displays images.
I need to add dynamically a jscript function on each image that use
the index value of the repeater

<asp:Repeater ID="ph" runat="server" DataSourceID="myDataSource">
<ItemTemplate>
<asp:HyperLink runat="server" ID="link"
NavigateUrl="javascript:Slides(INDEXREPEATER)">
<asp:Image runat="server" ID="img" ImageUrl='<%#
Eval("myPic") %>' />
</ItemTemplate>
</asp:Repeater>

How to replace the INDEXREPEATER by the current index ?

<%# DataBinder.ItemIndex %>
 
R

Riki

Stan said:
Hi,

I use a repeater that displays images.
I need to add dynamically a jscript function on each image that use
the index value of the repeater

<asp:Repeater ID="ph" runat="server" DataSourceID="myDataSource">
<ItemTemplate>
<asp:HyperLink runat="server" ID="link"
NavigateUrl="javascript:Slides(INDEXREPEATER)">
<asp:Image runat="server" ID="img" ImageUrl='<%#
Eval("myPic") %>' />
</ItemTemplate>
</asp:Repeater>

How to replace the INDEXREPEATER by the current index ?

<%#Container.ItemIndex %>
 
S

Stan SR

Great.. it works..
I thank you
but now, I have a little problem :(
When I use
<asp:HyperLink id="link" runat="server"
NavigateUrl='javascript:Slides(<%=Container.ItemIndex%>);' >bla
bla</asp:Hyperlink> it doesn't eval the Container.ItemIndex

So when I look at my source, I get
<a href="javascript:Slides(<%=Container.ItemIndex%>);">bla bla</a>


Any idea ??

Stan
 
R

Riki

Stan said:
Great.. it works..
I thank you
but now, I have a little problem :(
When I use
<asp:HyperLink id="link" runat="server"
NavigateUrl='javascript:Slides(<%=Container.ItemIndex%>);' >bla
bla</asp:Hyperlink> it doesn't eval the Container.ItemIndex

So when I look at my source, I get
<a href="javascript:Slides(<%=Container.ItemIndex%>);">bla bla</a>


Any idea ??

Stan

Try:

<asp:HyperLink id="link" runat="server"
NavigateUrl='<%# "javascript:Slides(" + Container.ItemIndex + ");" %>' >bla
bla</asp:Hyperlink>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top