Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataSet Validation, calling SetColumnError for multiple rows

$
0
0
Can anyone tell me how to raise an error for a column other than the one that is currently changing?

For example, let's say my dataset has 2 columns: age and favoriteColor.

My business "logic" says that if you're over 10 years old, you can't like yellow.

It's easy enough to make a sub that checks the age and favoriteColor values against each other. But if those data don't pass the test, I'd like to set an error for BOTH columns, telling the user to either change the age OR the favoriteColor (or both).

So, I say:
currentRow.SetColumnError("age", "You must be younger than 10 to enjoy yellow.")
currentRow.SetColumnError("favoriteColor", "If yellow is your favorite color, you cannot be over 10.")

BUT ONLY ONE OF THOSE LINES WORKS!
The column that is currently being changed gets its error updated, but the other column does not.
I would expect the form to get little red !s near BOTH fields, but I do not.

If I set age to 12 and then favoriteColor to yellow, I get a ! next to favoriteColor. If I then change age to 14, I get a second ! next to age.
BUT, if I then change age to 4, ONLY the ! next to age disappears. The ! next to favoriteColor remains.

Any help will be appreciated!

Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>