ListViewItem lvi = FindParent<ListViewItem>(sender as WebControl);
ListView lv = FindParent<ListView>(lvi);
int index = lv.items.IndexOf(lvi);
FindParent() goes through the visual tree
I want to get the index of the listviewitem within the listview. Unfortunately, the binding is not allowing me to convert from listviewitem to the bound class. It seems like there should be a simple solution but I cannot find it.
I do not want to select the item, just find its index. Selecting and deselecting is also not good enough. Currently the item is never found, and index is -1. Thank you for any help.
lol I figured it out. Funny how I find the answer 5 minutes after giving up and posting to the internet. Here is it if anyone else is having this same problem.
int index = lv.ItemContainerGenerator.IndexFromContainer(lvi);