开发者

Inject Index of Current item when binding to a repeater

I am binding a List<HtmlImage> to a repeater

Its actually a nested repeater and the list is one of the properties that the parent开发者_如何学Python repeater is binding to

I want to spit out the index of the current dataitem into the id property of the <li>

I've put a comment where I want the index to appear below

I have the following:

 <asp:Repeater ID="ImageListRepeater" runat="server" DataSource='<%# DataBinder.Eval(Container.DataItem, "Images") %>'>
                            <HeaderTemplate><ul></HeaderTemplate> 
                            <ItemTemplate>
                                <li id='<% **I want the Index Here**  %>'><%# RenderImage(Container.DataItem)%></li>
                            </ItemTemplate>
                            <FooterTemplate></ul></FooterTemplate>
    </asp:Repeater> 

What are the options?

thanks


Have you tried <%# Container.ItemIndex %> ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜