Reputation: 1775
So I have something like this:
Under the "Products" ComboBox there is a ListView that displays the new items that are added when the user clicks the "Add" button to add the selected product.
When the user makes a Product Descriptor selection for a product, I need to change a property of the associated data bound object. How do I access that object? I have a handler for the SelectedIndexChanged event of a given Product Descriptor ComboBox, but how do I get the DataItem of the row containing the ComboBox that had its selection changed?
I thought about ListView's ItemCommand event, but I can't see how I would use it in this case.
I also saw this post, in which one answer mentions storing ids in hiddenfields: DropDownList inside Repeater: How to handle SelectedIndexChange and get DataItem?
But in that case, how would I get the Ids from those hidden fields?
Thanks for your help!
Upvotes: 2
Views: 1668
Reputation: 1775
Tim Schmelter's answer led me to this answer:
Dim comboBox = CType(sender, RadComboBox)
Dim item = CType(comboBox.NamingContainer, ListViewItem)
Dim myListItem = myCollection(item.DataItemIndex)
Upvotes: 0
Reputation: 460168
You just have to cast the NamingContainer
of the DropDownList
:
var ddl = (DropDownList) sender;
var item = (ListViewItem) ddl.NamingContainer;
var rowView = (DataRowView) item.DataItem;
Upvotes: 2