Answer:
You can set a value of the cell using the data and column name of the CellEdit event arguments. Here is the code snippet for your reference,
<SfGrid DataSource="@Orders">
<GridEvents OnCellEdit="CellEditHandler" TValue="Order">GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" Mode="EditMode.Batch">GridEditSettings>
<GridSelectionSettings Mode=SelectionMode.Cell>GridSelectionSettings>
<GridColumns>
. . .
GridColumns>
SfGrid>
@code{
. . .
public void CellEditHandler(CellEditArgs
args)
{
if(args.ColumnName
== "Freight")
{
var cellvalue =
args.Data.GetType().GetProperty(args.ColumnName).GetValue(args.Data, null);
args.Data.GetType().GetProperty(args.ColumnName).SetValue(args.Data,
(Convert.ToDouble(cellvalue) * 2));
}
}
} |
Find
the sample for setting the cell value through OnCellEdit event from here.