jasonhick70
asked on
How do I add an incremental number when using the Databinder & ListView with ASP.Net
Hi there,
I'm trying to add an ID tag to an html element that is an incremental number (such as the current row index) in the ItemTemplate of a ListView in ASP.Net.
Does anyone know how to do this? I'm a bit new to all of this and not sure if it can be done using the Eval statement. Does it need to be programmatically in the code file?
Thanks for any help!
Regards,
Jason
I'm trying to add an ID tag to an html element that is an incremental number (such as the current row index) in the ItemTemplate of a ListView in ASP.Net.
Does anyone know how to do this? I'm a bit new to all of this and not sure if it can be done using the Eval statement. Does it need to be programmatically in the code file?
Thanks for any help!
Regards,
Jason
<asp:ListView ID="thumbList" runat="server">
<LayoutTemplate>
<div class="jcarousel-control">
<asp:PlaceHolder ID="itemPlaceHolder" runat="server"></asp:PlaceHolder>
</div>
</LayoutTemplate>
<ItemTemplate>
<img ID="1" src="/lib/img/prod/s/<%#Eval("SKU")%><%#Eval("Label")%>.jpg"></a>
</ItemTemplate>
<EmptyDataTemplate>
</EmptyDataTemplate>
</asp:ListView>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi there! Thanks for your help... in the end I used:
<%# Container.DataItemIndex %> as ItemIndex isn't a member of ListViewDataItem.
<%# Container.DataItemIndex %> as ItemIndex isn't a member of ListViewDataItem.
this will start with 1 instead of 0.....