Retrieve the current row of a DataBound List Control ( .net )

This has taken too long to figure out. If you want to get the current row number of an item being DataBound to a List control ( DataGrid, Repeater, etc ), use this line of code in your aspx code :

<%# Container.ItemIndex+1 %>

And if you want to get the number of records in your DataBound control, do this

<%# YourControlId.Items.Count %>

Where YourControlId is the id of your DataBound control, such as an ASP:Repeater

About Eric Fickes

Independent Internet Consultant by day. Skateboarder, Bass player, Husband and Father by night. You can hire me to build internet powered solutions
This entry was posted in .net, microsoft and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>