gpt4 book ai didi

asp.net - 如何计算 asp 转发器中的项目数?

转载 作者:行者123 更新时间:2023-12-01 16:00:53 25 4
gpt4 key购买 nike

如何使用 ASP.NET 计算转发器中的项目数?

我想展示一些类似的东西:

标记

第 1 页,共 5 页

ASPX

获取项目索引:(有效)

<%# DataBinder.Eval(Container, "ItemIndex", "") + 1%>

计算项目总数:(失败)

<%# DataBinder.Eval(Container.ItemIndex, rpt.Items.Count)%>

我更愿意在页面上执行此操作,但愿意接受建议和隐藏代码。

最佳答案

这是我得到的最好的解决方案

<asp:Repeater ID="rptGallery" runat="server"  >
<ItemTemplate>
<div>
<div>
<asp:Label ID="Number_of_element_in_repeater" runat="server"
Text='<%#Convert.ToString(((IList((Repeater)Container.Parent).DataSource).Count) %>'>
</asp:Label>

</div>
</div>
</ItemTemplate>
</asp:Repeater>

转发器中的项目数为:

Convert.ToString(((IList)((Repeater)Container.Parent).DataSource).Count)

关于asp.net - 如何计算 asp 转发器中的项目数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23565308/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com