Solved

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

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now