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

How do I select a row in the DataGrid and get the value of a row?

Thread ID:





123243 Feb 29,2016 03:25 PM UTC Mar 29,2016 07:27 AM UTC UWP 4
Tags: SfDataGrid
Garling Beard
Asked On February 29, 2016 03:25 PM UTC

I am using the SfDataGrid (UWP) with data from SQLite, I need to select a row and get the value of a column so I can pass the data to another XMAL page and display the details.   

Garling Beard
Replied On February 29, 2016 04:03 PM UTC

I believe I found something that will work:

 this.dgCustomers.SelectionChanging += dgCustomers_SelectionChanging;

void dgCustomers_SelectionChanging(object sender, GridSelectionChangingEventArgs e)
            var record = dgCustomers.GetRecordAtRowIndex(dgCustomers.SelectionController.CurrentCellManager.CurrentRowColumnIndex.RowIndex);
            if (record == null)
            var colIndex = dgCustomers.ResolveToGridVisibleColumnIndex(dgCustomers.SelectionController.CurrentCellManager.CurrentRowColumnIndex.ColumnIndex);
            if (colIndex >= 0)
                var column = dgCustomers.Columns[colIndex];
                var cellValue = dgCustomers.View.GetPropertyAccessProvider().GetValue(record, column.MappingName);


This gives me the value of the selected cell. 

Sivakumar R [Syncfusion]
Replied On February 29, 2016 04:05 PM UTC

Hi Garling,

Yes, you can use SelectionChanging as you mentioned or SelectionChanged event with SfDataGrid.SelectedItem.

private void Button_Click(object sender, RoutedEventArgs e)
    // Get the selected items of SfDataGrid
    var reflector = this.dataGrid.View.GetPropertyAccessProvider();
   var row = this.dataGrid.SelectedItem;
        foreach (var column in dataGrid.Columns)
            //Get the value from data object based on MappingName
            var cellvalue = reflector.GetValue(row, column.MappingName);
            //Returns the display value of the cell from data object based on MappingName
            //var displayValue = reflector.GetFormattedValue(row, column.MappingName);

Refer below KB for sample and details:


Garling Beard
Replied On March 28, 2016 03:50 PM UTC

I have this working but now I need to get the values of multiple columns in the row for example:

var col1 should be column[0]  
var col2 should be column[3]

How can I do this? 

Srinivasan Vasu [Syncfusion]
Replied On March 29, 2016 07:27 AM UTC

Hi Garling,

We have analyzed your query. You can refer below code example for get particular column value from selected row in SfDataGrid.

Code snippet:

private void Button_Click_1(object sender, RoutedEventArgs e)


            if (this.dataGrid.SelectedItem != null)



                var reflector = this.dataGrid.View.GetPropertyAccessProvider();

                var row = this.dataGrid.SelectedItem;

                //Get the value from data object based on Column index              

                var cellvalue = dataGrid.Columns[1].MappingName; // Use any column index

                var cell_value = reflector.GetValue(row, cellvalue);// Reflect the cell Value              



We have also prepared the sample based on this and please find the sample under the following location,

Sample: http://www.syncfusion.com/downloads/support/forum/123243/ze/CellValue1895583630



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