Solved

How do I add an incremental number when using the Databinder & ListView with ASP.Net

Posted on 2009-05-20
3
402 Views
Last Modified: 2013-11-25
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
Comment
Question by:jasonhick70
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 10

Accepted Solution

by:
orbulat earned 250 total points
ID: 24438496
how about this ?
<%# Container.ItemIndex%>
0
 
LVL 3

Expert Comment

by:techprocess
ID: 24449846
<%# Container.ItemIndex + 1%>
this will start with 1 instead of 0.....
0
 

Author Closing Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question