We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Select a line in the detail section of a Master-Detail datagrid

Thread ID:





120886 Oct 25,2015 07:48 AM UTC Nov 5,2015 09:50 AM UTC WPF 9
Tags: SfDataGrid
Asked On October 25, 2015 07:48 AM UTC


Is there a way to select an item dynamically (with line code) in the detail part of a master-detail datagrid ?

I try to set the CurrentItem / SelectedItem with the Behaviour workaround but it does not work to set only to get.


Sowndaiyan Paulpandi [Syncfusion]
Replied On October 26, 2015 09:17 AM UTC


Thanks for using Syncfusion Products.

You can set the value to CurrentItem as well as SelectedItem in SfDataGrid like the below code example.

Code Example[C#]:

void FirstDetailsViewDataGridSelectionChanged(object sender, GridSelectionChangedEventArgs e)
            var OrderDetailCollection = this.AssociatedObject.DataContext as ViewModel;
            var CurrentItemDetails = OrderDetailCollection.OrdersDetails[2].OrderDetails[0] as OrderDetails;
            var SelectedItemDetails = OrderDetailCollection.OrdersDetails[3].OrderDetails[0] as OrderDetails;
            //Set the Specific OrderDetails to the CurrentItem/SelectedItem
            (e.OriginalSender as SfDataGrid).CurrentItem = CurrentItemDetails;
            (e.OriginalSender as SfDataGrid).SelectedItem = SelectedItemDetails;
            this.DetailsViewSelectedItem = (e.OriginalSender as SfDataGrid).SelectedItem;
            this.DetailsViewSelectedItems = (e.OriginalSender as SfDataGrid).SelectedItems;
            this.DetailsViewCurrentItem = (e.OriginalSender as SfDataGrid).CurrentItem;

We have prepared a sample for setting the values to the CurrentItem and SelectedItem of SfDataGrid using the “Behavior” concept. In this sample, we have set the particular record to SfDataGrid.CurrentItem  and SfDataGrid.SelectedItem in the SelectionChanged Event and you can download that sample from the below location,

Sample Link: http://www.syncfusion.com/downloads/support/forum/120886/ze/MasterDetailsView-2006844171


Replied On October 27, 2015 06:24 AM UTC


thanks for your proposal but unfortunatley it does not perform what I want.

I would have to set the currentitem / selecteditem only when I launch an Add action on the collection in the view model to set the current row on the added item.

If I add your code, the selected item is always set to the same row.

Is there a way to do that ?

Thanks again for your help.


Sowndaiyan Paulpandi [Syncfusion]
Replied On October 29, 2015 03:49 AM UTC



We have analyzed your query. We regret to inform you that it is not possible to set the CurrentItem / SelectedItem when performing the Add action in view model. Because it is not possible to get the exact DetailViewDataGrid in Add action. So we recommend you to use the “Behaviour” concept.

Please let us know if you require further assistance on this.


Replied On October 31, 2015 06:57 PM UTC

Is there a way to set always the first line after I add a new record in the details part of the Datagrid ?

Sowndaiyan Paulpandi [Syncfusion]
Replied On November 3, 2015 03:58 AM UTC


We have analyzed your query and we have prepared the sample based upon your requirement “Set the CurrentItem / SelectedItem in add action of the DetailsViewDataGrid” . You can download the sample from the following location.

Sample Location:

In this sample we have add the record into the DetailsView on a ButtonClick action using ICommand. Within this action we have set the CurrentItem / SelectedItem to the Corresponding DetailsViewDataGrid.

Please let us know if you have any other concern.


Replied On November 3, 2015 06:56 PM UTC

It's a good way to achieve my requirement but there is again a little problem.

With your sample the RecordIndex is set to 0 and so the first Child Datagrid is always updated even if I added a record in the second one.

Is there a way to find the RecordIndex currently selected to update the good child datagrid ?


Farjana Parveen Ayubb [Syncfusion]
Replied On November 4, 2015 11:50 AM UTC

Hi Marquant,
We have analyzed your query and we have passed the recordIndex as zero for your reference to select the first record while adding in the first DetailsViewDataGrid. You have to pass the corresponding parent recordIndex of particular DetailsViewDataGrid to GetDetailsViewGrid method. Please refer the below sample for your reference.
Sample Link: DetailsViewDemo

In the above sample, we got the recordIndex by resolving the rowIndex using SfDataGrid.ResolveToRecordIndex method. If the issue still persists, could you please modify the above sample to replicate the issue that would be more helpful for us to provide you the better solution.

Farjana Parveen A

Replied On November 4, 2015 04:29 PM UTC

Thanks it works perfectly

Sowndaiyan Paulpandi [Syncfusion]
Replied On November 5, 2015 09:50 AM UTC

Hi Marquant,

Thanks for the update.

Please let us know if you need further assistance.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon