Hello!
i have a DataTable with a key made of 2 columns. Suppose these columns are ID1 and ID2, also the datatable is the source of the grid.ID1 is a hidden column, instead ID2 is Visible and its EditorControl is set to an UltraCombo. The ultracombo is populated from some data and has also the value property set. The purpose is that when the user select an item from the combo, ID1 has to be setted to X value and ID2 to the value of the selected item on ultracombo. For this, i handle the after row insert and tried with this code but it does not work
e.Row.Cells["ID1"].Value = "TheFirstkeyValue";
The problem is that i get the exception from the datatable which is "NoNullAllowedException". The column ID1 does not allow Why? i immagine that this statement e.Row.Cells["ID1"].Value = "TheFirstkeyValue"; will do its job and set the value of column ID1 not only on the grid but also on the datasource.
Maybe i'm not handling the correct event to initialize the ID1 column?
thank you
AfterRowInsert is probably the wrong place to do this. That event fireswhen you create a new row, not when that new rows is saved. So the value of the ID2 colmn likely hasn't even been set when AfterRowInsert fires. I think you need to use BeforeRowUpdate and check the IsAddRow property on the row to see if it's a new or existing row.
Or maybe use the CellChange event and trap for when the ID2 cell changes.
Hi Mike,
I have tried that events but it does not work.
The InitializeRow event solved the problem.