Hi all,in my UltraGrid, when the user change a cell's value, I fire this event:
private void ultraGridBran_CellChange(object sender, CellEventArgs e) { try { ultraGridBran.UpdateData(); dataSet1.Registrations.AcceptChanges(); }
but none update appears in the database. Maybe something is missing?
(dataSet1.Registrations is my DataMember property of the Grid).
Thanks in advance.
Luigi
Hi Luigi,
The grid has no interaction with the database, it only works with the local DataSource. The code you have here will save your changes to the grid's DataSource (presumably dataSet1). You are then committing those changes to dataSet1, which does not make sense, since the dataSet has not yet written these changes to the database.
For information on how to write changes from a DataSet back to the database, you should refer to Microsoft's documentation. The WinGrid has no involvement in this process.
Also, on an unrelated note, you should be aware that calling UpdateData in the CellChange event could be dangerous and is probably inefficient. CellChange is going to fire on every keystroke. So if your user types in a word, you will be updating the data set for every character they type. And the value of the cell may not be valid as the user is typing. For example, if the user is editing a date field, the first digit they type will not be a valid date - because a single digit is not enough information. So this will result in an error.