How to show row number in DataList

N

Nathan Sokalski

Here are two suggestions. Use the ItemDataBound event to set a property of a
control (probably the Text property of a Label in your case). You can do
this using either e.Item.ItemIndex or create a global integer variable and
increment it by 1 each time the ItemDataBound event is called (I recommend
using e.Item.ItemIndex because it is less code). Keep in mind that
e.Item.ItemIndex is 0 based, so depending on what you want you may want to
use e.Item.ItemIndex+1. If you have any questions, just ask. Good Luck!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top