【问题标题】:Inject Index of Current item when binding to a repeater绑定到中继器时注入当前项目的索引
【发布时间】:2010-12-15 21:38:06
【问题描述】:

我正在将List<HtmlImage> 绑定到转发器

它实际上是一个嵌套转发器,列表是父转发器绑定的属性之一

我想把当前dataitem的索引吐到<li>的id属性中

我已经在我希望索引出现在下方的地方发表了评论

我有以下几点:

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

有哪些选择?

谢谢

【问题讨论】:

    标签: .net data-binding binding repeater


    【解决方案1】:

    你试过&lt;%# Container.ItemIndex %&gt;吗?

    【讨论】:

    • 谢谢...我知道是这样的。我试过 Databinder,中继器的 id,Datasource,但智能感知显示这些都没有索引属性
    猜你喜欢
    • 1970-01-01
    • 2015-02-08
    • 2012-05-25
    • 2010-09-20
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多