I am using the ListView Control with the following datasource List<MyObject>
On my listview control i have an OnItemDataBound
My question is how do get the current value of MyObject. Ie myObj[5].FirstName
protected void ItemsListViewDataBound(object sender, ListViewItemEventArgs e) { // I want to do some kind of a cast here
}
protected void MyListView_DataBind(object sender, ListViewItemEventArgs e){
if(e.Item.ItemType == ListViewItemType.DataItem){
MyObject p = (MyObject)((ListViewDataItem)e.Item).DataItem;
}
}
You'll want to do the type check so that you don't try and do a cast when you're working on say, the header item.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With