datagridview delete calls DefaultValuesNeeded




I have a datagridview who's datasource is a view (from oracle) but it
has a couple of combo boxes in it that when changed updates the
underlying table that this view is based off.

Anyway, it seems to work fine, however when I delete a row, and there
is only one row it deletes fine however it calls the
"defaultvaluesneeded" method for the datagridview and creates new IDs

Then when I go to enter data in what appears to be the first row, it
does not create new ID's for this row which causes problems with
validation (cell validation method updates the underlying table) - and
I do not know what happens to the new row that was apparently created
when the "defaultvaluesneeded"
method was called after the delete...

Has anyone had this problem before or perhaps can show me the error of
my ways?




Sep 21, 2011
Reaction score
Had the same problem for datagridviews, that are bounded to a BindingSource. Manifests after deleting the last row in the datagridview - if a row is added by typing in values, not all cells have default values set. Effect is not related to column order or visibility; in my case, one integer column value was set, but another was not. A string value was also set ok. Maybe the bug related to the datatype - works one time for each datatype?

The problem was solved as follows: to set initial cell values, instead DatagridView.DefaultValuesNeeded event use BindingSource.AddingNew event. At least, it worked for me.

If there is a similar event for DataTable, it might also work.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question