当绑定到中继器时,注入当前项目的索引 [英] Inject Index of Current item when binding to a repeater

查看:162
本文介绍了当绑定到中继器时,注入当前项目的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将列表< HtmlImage> 绑定到中继器

它实际上是一个嵌套的中继器和列表是父中继器绑定到的属性之一

Its actually a nested repeater and the list is one of the properties that the parent repeater is binding to

我想将当前dataitem的索引发送到的id属性中< li>

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

我有以下内容:

 <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> 

有什么选择?

谢谢

推荐答案

你尝试了<%#Container.ItemIndex%>

这篇关于当绑定到中继器时,注入当前项目的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆