Trick for unique row id when binding

Discussion in 'ASP .Net' started by Karl Seguin, Oct 27, 2004.

  1. Karl Seguin

    Karl Seguin Guest

    I just discovered this and I'm sure I'm not the first, but it can be useful
    so thought I'd post it. If you need a unique Id when binding, you can
    simply use <%# Container.ItemIndex %>. For example, if you are doing some
    javascript, you can do something like:

    <itemTemplate>
    <tr id='<%# "Row_" + Container.IndexIndex%>'>
    <td>...</td>
    <td>...</td>
    </tr>
    </itemTemplate>

    Which will give each tr an unique id without having to use a counter or the
    OnItemDataBound...note that the first row is = 0

    Karl
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/
    Karl Seguin, Oct 27, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2hhd24=?=

    Magic Trick Datagrid Delete Row

    =?Utf-8?B?U2hhd24=?=, Apr 6, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,449
    =?Utf-8?B?U2hhd24=?=
    Apr 6, 2005
  2. Christopher Brian  Colohan

    Unique Integer Types -- a useful C++ trick

    Christopher Brian Colohan, Nov 19, 2004, in forum: C++
    Replies:
    2
    Views:
    511
    Jonathan Turkanis
    Nov 19, 2004
  3. ToshiBoy
    Replies:
    6
    Views:
    841
    ToshiBoy
    Aug 12, 2008
  4. D
    Replies:
    0
    Views:
    203
  5. Token Type
    Replies:
    9
    Views:
    349
    Chris Angelico
    Sep 9, 2012
Loading...

Share This Page