Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-05-20
3
Medium Priority
?
411 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 1000 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

610 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