dataGrid updating dataSet

rogerm

Member
Joined
Apr 6, 2007
Messages
15
Programming Experience
3-5
Why when I create a new row in a dataSet and type info in a dataGrid cell representing a field in the new row that I have to select a row above it and then go back to the newly created row for the entered string to become recognized in the dataSet???

I have dgA representing dsA and dgB representing dsB. When dgA.currentCellChanged occures I take this info and fill dsB. -All works fine.

When I select a row below the last row in the dgA I add a new row in the underlying dsA and then type into the dgA cell.

Why is the info I type in the new row cell not recognized imediately as I type it?
 
How could it be? When you create a new row in the grid every cell contains no value. What if some of the columns in your DataTable didn't allow null values? How would that work? The .NET data-binding mechanism is smart enough to wait until you've finished entering all the values for the new row before it tries to push the data to the underlying data source. At that point the data is validated and only if it passes will the row be added to the DataTable. When you leave the row in the grid that signifies to the grid that you're finished entering the values so the data gets validated and pushed to the data source then. If you want to programmatically force the data to be pushed to the data source then you can call the EndCurrentEdit method of the associated CurrencyManager. Note that the operation will fail, though, if the data does not pass validation.
 
Back
Top