Hello Friends,
The following code returns NULL when DeleteRow "endDelete" event is trigered:
Thank you for your help and time,
Regards,
Rafael M.
protected void ejGrdAD2_DeleteRow(object sender, GridEventArgs e)
{
EditAction2(e.EventType, e.Arguments["data"]);
}
protected void EditAction2(string eventType, object record)
{
List<DAP> data = Session["DS2"] as List<DAP>;
Dictionary<string, object> KeyVal = record as Dictionary<string, object>; // here's the problem ...
// record has the values like in a second level and assigns to KeyVal only the first level that is empty
// only occurs when eventType is "endDelete" (see the attached image)
if (eventType == "endEdit") { //// endEdit Works OK ...
DAP value = new DAP();
foreach (KeyValuePair<string, object> keyval in KeyVal) {
... }
else if (eventType == "endAdd"){ //// endAdd Works OK ...
... }
else if (eventType == "endDelete"){ //// ERROR in next line ... KeyVal is null ...
foreach (KeyValuePair<string, object> keyval in KeyVal) {
if (keyval.Key == "nKeyField1"){
DAP value = data.Where(d => d.nKeyField1 == (int)keyval.Value).FirstOrDefault();
data.Remove(value);
}
}
}
Session["DS2"] = data;
this.ejGrdAD2.DataSource = data;
this.ejGrdAD2.DataBind();
bindDAP1();
bindForeignKeys();
}
Attachment:
syncfusion_grid_20170424_155159_92de5cfd.zip