Link to home
Start Free TrialLog in
Avatar of jasonhick70
jasonhick70Flag for United Kingdom of Great Britain and Northern Ireland

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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of orbulat
orbulat
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of techprocess
techprocess

<%# Container.ItemIndex + 1%>
this will start with 1 instead of 0.....
Avatar of jasonhick70

ASKER

Hi there! Thanks for your help... in the end I used:
<%# Container.DataItemIndex %> as ItemIndex isn't a member of ListViewDataItem.