EnableEdit in GridDataBoundGrid not working as expected?

The description of EnableEdit is: A value indicating if the grids supports editing records if the underlying datasource allows it.

So what do I expect:
If I set EnableEdit to false, one should not be able to change values from EXISTING records!

What happens:
I cannot change values from existing records, but if I add a new record in the grid (I''m on the last record and just go one down so that I get a new empty record), I am not able to input any values at all in that new record?? How can this supposed to be working like this? This is not what the description says, since a new records is not yet a record in the underlying datasource yet!

Question: How can I make sure people cannot alter fields of existing records but are still able to add new records in a GridDataBoundGrid?

2 Replies

AD Administrator Syncfusion Team September 29, 2006 10:09 AM UTC

Hi Filip,

This can be acheived by handling the CurrentCellStartEditing event and set the EnableEdit property to TRUE when the AddNewRecord is activated. Below a code snippet

private void grid_CurrentCellStartEditing(object sender, CancelEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
if( grid.Binder.IsAddNew || grid.Binder.IsAppendRow)
{
grid.EnableEdit = true;
}
else
grid.EnableEdit = false;
}

Sample : http://www.syncfusion.com/Support/user/uploads/GDBGEnableEdit_50b6900a.zip

Let me know if you trying something different.

Best Regards,
Haneef


AD Administrator Syncfusion Team September 29, 2006 11:00 AM UTC

Thank you for your quick response,
I had found another way to achieve this
using the code and examples from http://www.syncfusion.com/support/forums/message.aspx?MessageID=20985

but I will try your solution too because it looks more elegant!

Loader.
Up arrow icon