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. Image for the cookie policy date

How to get value from a cell in sfdatagrid?

Y try with this code, but not working, maybe this code is for Xamarin Forms
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;
                }
            }
            string value = cellValue.ToString();
        }

https://es.stackoverflow.com/questions/106565/c%C3%B3mo-obtener-los-valores-de-una-celda-o-fila-de-un-sfdatagrid-syncfusion-xamar

1 Reply

AN Ashok N Syncfusion Team October 3, 2017 01:17 PM UTC

Hi Customer,  
 
Thanks for contacting Syncfusion support. 
 
We have checked your code snippet and you are trying to convert object to string (SfDataGrid.GetCellValue method returns object) using as so values not convert to string. You can achieve your requirement by converting the value using ToString method, please refer the below code example: 
 
private void OnGetCellValue(object sender, EventArgs e) 
{ 
    string cellValue = null; 
    foreach (var column in sfGrid.Columns) 
    { 
        if (column.MappingName == "CustomerID") 
        { 
            var rowData = sfGrid.GetRecordAtRowIndex(2); 
            cellValue = sfGrid.GetCellValue(rowData, column.MappingName).ToString(); 
        } 
    } 
    string value = cellValue; 
} 
 
Regards, 
Ashok 


Loader.
Live Chat Icon For mobile
Up arrow icon