How to validate a DataGridView Cell is not empty, when the user never enters the cell?
I just want to check and make sure that a cell has some data in it. My situation is I have 3 columns in a DataGridView. When someone adds a new record the rows are blank. The first column is a ComboBox, the next two are just plain text. If someone just enters in one of the text boxes and doesn't select from the combobox, when they press save an exception is thrown since the DB wants that combobox value. How can I check that cell and make sure there is a value? CellValidating won't work since the cell never gets focus and loses focus.
I did end up checking the column in the RowValidating event and looped through the开发者_运维技巧 columns, checking if they are empty. This feels dirty, is that the only way?
Validating controls? They can give you both client side and server side validation.
http://msdn.microsoft.com/en-us/library/aa479013.aspx
精彩评论