Solved

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

Posted on 2009-05-20
3
400 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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.…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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