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

datagrid button code behind

Thread ID:





132577 Sep 9,2017 11:21 PM UTC Sep 12,2017 02:44 PM UTC WPF 3
Tags: SfDataGrid
David Gammon
Asked On September 9, 2017 11:21 PM UTC

I have a button inside a datatemplate of the sfdatagrid that I want to use to activate a detail edit page for the selected record.  Can you show me an example of this using visual basic?

Muthukumar Kalyanasundaram [Syncfusion]
Replied On September 11, 2017 05:06 PM UTC

Hi David, 
Thank you for contacting Syncfusion support. 
We have checked your query. We couldn’t understand your requirement clearly. So could you please share some more information about your query as like,  
  1. When you select button to enter the edit mode of selected record ?
  2. When you click on the button to navigate the focus to the another window to shows the selected records of DataGrid ?
This would be more helpful for us to proceed further. 
Muthukumar K 

David Gammon
Replied On September 11, 2017 05:13 PM UTC

#2  When I click the button I want to navigate to another page and display the selected record from the datagrid.

Muthukumar Kalyanasundaram [Syncfusion]
Replied On September 12, 2017 02:44 PM UTC

Hi David, 
Thanks for the update. 
You can achieve your requirement “to display the selected record from the datagrid when navigating to another page” by binding SelectedItem to TwoWay  to the view model of the navigating page  using  SfDataGrid.SelectedItem property.  Please refer the below code example: 
Code Snippet: Xaml 
<syncfusion:SfDataGrid x:Name="dataGrid" 
                        <!--Binding selected item in grid--> 
                        SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  
                        ItemsSource="{Binding GDCSource}" 
Setting view model as  Datacontext to Navigating page and showing SelectedItem value in TextBlock: 
Code Snippet: VB 
Private Sub Button_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) 
                Dim win As New Window2() 
                win.DataContext = (TryCast(Me.DataContext, PersonModel)).SelectedItem 
End Sub 
<Grid >        
    <!--Binding LastName of selected items--> 
    <TextBlock HorizontalAlignment="Center"  
                VerticalAlignment="Center" Width="120" Height="50"  Text="{Binding LastName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"  /> 

Please let us know if you have any other questions. 

Muthukumar K 


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