Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 417
  • Last Modified:

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

0
jasonhick70
Asked:
jasonhick70
1 Solution
 
orbulatCommented:
how about this ?
<%# Container.ItemIndex%>
0
 
techprocessCommented:
<%# Container.ItemIndex + 1%>
this will start with 1 instead of 0.....
0
 
jasonhick70Author Commented:
Hi there! Thanks for your help... in the end I used:
<%# Container.DataItemIndex %> as ItemIndex isn't a member of ListViewDataItem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now