Hi Joseph,
Thank you for contacting Syncfusion support.
Based on provided information we have checked the provided sample. In your underline property of Amount is declared in Decimal type. In Set value defined the value normally it considers as integer. So, Invalid Cast Exception occurs. You can resolve the issue by type case value or declared the underline property as integer. Please refer the below code snippet,
Type case Value c# Code snippet:
|
public class OrderLine
{
public int ID { get; set; }
public string Product { get; set; }
public double Quantity { get; set; }
public decimal Amount { get; set; }
}
private void DataGrid_CurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs e)
{
//TypeCast the Valuebased on under line collection type dataGrid.View.GetPropertyAccessProvider().SetValue(e.Record,nameof(OrderLine.Amount),(decimal)9999);
} |
Change the Underline property type C# Code snippet:
|
public class OrderLine
{
public int ID { get; set; }
public string Product { get; set; }
public double Quantity { get; set; }
//Change the Underline collection type as integer
public int Amount { get; set; }
}
private void DataGrid_CurrentCellValueChanged(object sender, CurrentCellValueChangedEventArgs e)
{
dataGrid.View.GetPropertyAccessProvider().SetValue(e.Record, nameof(OrderLine.Amount), 9999);
} |