Articles in this section
Category / Section

How to get the cell value of specific row and column in Xamarin.Forms DataGrid?

1 min read

You can get the cell value of specific row and column in SfDataGrid by using the SfDataGrid.GetCellValue method. You need to pass the underlying data object and the mapping name of the column to find the cell value.

<StackLayout>
  <Button Grid.Row="0" 
          Text="Cell value"
          Clicked="OnGetCellValue">
  </Button> 
  <syncfusion:SfDataGrid Grid.Row="1"
                        x:Name="datagrid"
                        AutoGenerateColumns="True"
                        ColumnSizer="Star"
                        ItemsSource="{Binding OrdersInfo}"/>
</StackLayout>

 

The below code illustrates how to get the cell value of the specific row and column in a button click.

string cellValue;
private void OnGetCellValue(object sender, EventArgs e)
{
    foreach (var column in datagrid.Columns)
    {
        if (column.MappingName == "CustomerID")
        {
            var rowData = datagrid.GetRecordAtRowIndex(2);
            cellValue = datagrid.GetCellValue(rowData, column.MappingName) as String;
        }
    }
    DisplayAlert("ColumnName", cellValue , "Cancel");
}

 

Screenshot:

Table

 

Sample Link:

How to get the cell value of specific row and column?


Conclusion

I hope you enjoyed learning about how to get the cell value of specific row and column in DataGrid.


You can refer to our Xamarin.Forms DataGrid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied