So I've got two listviews; one nested inside the other.
The parent is being bound to a collection of objects that contain fields such as MaxPrice, MinPrice, and SuggestedProducts.
The nested one is being bound to the SuggestedProducts collection of the parent item.
How could I reference MaxPrice and MinPrice in the nested listview? Is it even possible?
If you need any clarification, leave me a comment and I'll update my question.
Thanks!
Edit: This is an ASP.NET ListView
I just had the same issue and I found another solution that I would like to share.
From the ItemDataBound event on the child nested ListView you can get the reference from the parent doing something like this:
ListViewDataItem CurrentParentItem = (ListViewDataItem)e.Item.Parent.Parent.Parent;
ParentObject parentObject = CurrentParentItem.DataItem as ParentObject
//Then you can access to parentObject.MaxPrice & parentObject.MinPrice
Hope this help people with the same problem
If your SuggestedProduct class would have a reference back to its parent class X (so you'd have a bidrectional data model: X has a collection of SuggestedProducts and SuggestedProduct has an object reference to X) you could give SuggestedProduct properties like MinPrice { get {return parentX.MinPrice;} } (and perhaps also set) and then use Eval("MinPrice") (and perhaps also Bind) in your nested ListView.
Just as an idea in case that modification of your class model is a real and easy option.
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