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

Tags: , , , ,

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Reply