How can I find the ItemIndex in a ListView?

A

aleko

Hi,

I was in the middle of converting some old Repeater code to use a
ListView, when I discovered that the ListViewItem class doesn't have
an ItemIndex property. Is there another way of getting the index of
the current list item?

Thanks,

Aleko
 
G

Guest

Hi,

I was in the middle of converting some old Repeater code to use a
ListView, when I discovered that the ListViewItem class doesn't have
an ItemIndex property. Is there another way of getting the index of
the current list item?

Thanks,

Aleko

When ListView is clicked the ItemCommand() event is raised and a
ListViewCommandEventArgs object is passed, which can be used to
retrieve control values such as an index of the current row.

protected void ListView1_ItemCommand(object sender,
ListViewCommandEventArgs e)
{
... (ListViewDataItem)e.Item.DisplayIndex

See more:

http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.listviewcommandeventargs.aspx
http://msdn2.microsoft.com/en-us/library/bb398790.aspx
 
A

aleko

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

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top