User (Old forums)MemberApril 29, 2008 at 3:09 pmPost count: 23064
I’ve looked through many many posts on this forum but I’m not getting the answer I’m looking for. (I suspect I’m missing something obvious)
I’ve got a Master Detail grid bound to Linq Bindinglists. When a row is inserted to the grid, I want to manualy write the row data back to our system via a web service call. I’m successfully doing this on the master section, by overriding the InsertionRow OnEndingEdit event, and then simply taking the last element in the Master BindingList as the item I need to write back to our system. This might not be the most elegant, but it works.
On the insertion row in the details section I have a problem: I can no longer just take the last item in the bindinglist. I need to find the item that was added, and I also need to know to which item from the master section grid it was added. I don’t see an easy way to find a reference to the item that was just added (or the item that will be added depending on which event you handle).
Jenny, from your other posts it seems like the loaded event on the InsertionRow might be of use, but I don’t see how? I don’t see how a reference to the InsertionRow itself or the parent grid will help?
Imported from legacy forums. Posted by Henry (had 3786 views)Xceed SupportMemberApril 30, 2008 at 9:10 amPost count: 5658
The InsertionRow’s DataContext is the System.Data.DataRow (assuming you are using DataTables, otherwise use whatever the type of your data item is). Therefore, you could handle the DetailConfiguration.InitializingInsertionRow event and get the data item there. Something like this:
private void OnInitializingInsertionRow( object sender, InitializingInsertionRowEventArgs e )
System.Data.DataRow row = e.InsertionRow.DataContext as System.Data.DataRow;
Imported from legacy forums. Posted by Jenny [Xceed] (had 1344 views)User (Old forums)MemberMay 4, 2008 at 4:08 pmPost count: 23064
Again you save me from certain insanity!
That works. Thank you very much.
Imported from legacy forums. Posted by Henry (had 760 views)User (Old forums)MemberMarch 10, 2009 at 7:44 pmPost count: 23064
I’m not sure how this post helped Henry, as it is not working for me.
I’ve got the same exact problem. I need to access the parent object when the InsertionRow is used, in order to properly the new child object. The parent object is absolutely essential to properly creating the child object.
I created the above event handler code in the C# codebehind, and wired up the XAML similar to above, but the event does not fire prior to the grids InitializeNewItem or CreatingNewItem events, so this event handling is useless to me.
How can I access the parent (or Master) object from the InitializeNewItem or CreatingNewItem events? Please don’t tell me to look at the DataGrid.SelectedItem or DataGrid.GlobalCurrentItem, as a different parent row could be selected than the parent row that is expanded and had a double click happen in the DetailConfiguration’s insertion row.
Thanks in advance….
Imported from legacy forums. Posted by Ryan (had 4170 views)
- You must be logged in to reply to this topic.