Is it any easy way to validate you can check the value of entered data and show appropriate error message for that value.for example if value is null or empty and the field is not nullable, you can show a message indicating that the value cannot be empty. @masoudkeshavarz I've tested with entity framework 4.0, it works for me.I think your situation is different, can you explain exactly what you are doing, like how do you provide the data source for gridview, which column type do you change at runtime that doesn't enter Why not then map the EF classes into DTOs or View Models?Then you bind to simple objects, validate as soon or as late as you want, and get database/domain/whatever specific error when you map them back.So you may have to resort to making your own if you need to track "Is Dirty" on each row.But there is an event that comes with the native dirty settings, to log any changes you might need.Unfortunately the code only allows integers to be entered in the datagridview.
Alternately, if a user tries to insert a string into an integer column, they get a very long error message which isn't user friendly at all.I am able to validate my value properly but when I try to change it to something valid I get a Data Error. You should never attempt to change the cell value in the handler for this event, because unless you cancel the event (in which case the user is stuck in edit mode), the cell value is set to the value from the editing control immediately after the event finishes.This, therefore, undoes any action you perform in the handler.How am i supposed to edit the code so that it does not generate this error?But this is not working, what should be the type for a number column? First this depends on a datatype in your source collection. Best if you put conditional a breakpoint in this method for certain cell (column).i think you are looking for datagrid view text box column validation right ?