views:

87

answers:

1

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?

A: 

Validating controls? They can give you both client side and server side validation.

http://msdn.microsoft.com/en-us/library/aa479013.aspx

Han
Winforms. not asp.net
nportelli
This is awkward...I think your way is fine, but don't leave validation logic (even empty value check) in the RowValidating method, all that the RowValidating method should do is pack up all the data there is and hand it to the validation logic. This is all I can think of.
Han