468,278 Members | 1,563 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,278 developers. It's quick & easy.

Repeater and Index Value

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
Jan 22 '07 #1
5 11225
Stan SR wrote:
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 %>

--

Riki
Jan 22 '07 #2
Stan SR wrote:
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 %>

--

Riki
Jan 22 '07 #3
Thanks Riki, but it seems it doesn't work. I get an error
Stan
"Riki" <ri**@dontnagme.coma écrit dans le message de news:
e7**************@TK2MSFTNGP03.phx.gbl...
Stan SR wrote:
>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 %>

--

Riki

Jan 22 '07 #4
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.ItemIn dex%>);' >bla
bla</asp:Hyperlinkit 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
"Riki" <ri**@dontnagme.coma écrit dans le message de news:
ui**************@TK2MSFTNGP05.phx.gbl...
Stan SR wrote:
>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 %>

--

Riki

Jan 22 '07 #5
Stan SR wrote:
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.ItemIn dex%>);' >bla
bla</asp:Hyperlinkit 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>

--

Riki
"Riki" <ri**@dontnagme.coma écrit dans le message de news:
ui**************@TK2MSFTNGP05.phx.gbl...
>Stan SR wrote:
>>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 %>

--

Riki

Jan 22 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by michael | last post: by
2 posts views Thread by Dot Net Work | last post: by
reply views Thread by tedpottel | last post: by
3 posts views Thread by Robert Bevington | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.