I’ve never looked much into all what .NET offers for user input validation because to start with I dislike the way they will typically not let you unfocus a control unless you enter the right data (I believe the DataGridView does this).
On the other hand, I found that I often need to validate what I’ll describe below and I wonder if sticking to .NET standards here will make it any easier.
I’ll typically have a dialog box that among other controls will have two combo boxes: one to select a data table among existing tables, and one to select a column among the columns in the currently selected table. This is easy enough so far, but since this is a dialog, I need to show the values that were selected the last time the dialog was shown if they still exist in the database, or otherwise select some other column if the table still exists, or select another table and column if there is any table and warn the user that his selection has changed, or if there are no tables simply show a message and close the dialog.
Of course this is not the only case. Sometimes it will be a bit more complex and every time I will try to figure out again what’s the best way to handle it. I wonder if there is already a pattern, particularly one that .NET offers I can apply to the case I describe above? If so, I’m sure I’ll figure out how to apply it to other cases.
The answer will depend quite a bit on your implementation specifics.
However, what we finally settled on for this was to pass the existing display and value values to the method that retrieves the data.
Once the data is retrieved, we check to see if the missing data is present in the retrieved data and, if it is, we add a record to store the display and value values to the collection of data that is returned.
Implementing this functionality at the point of data retrieval allows us to support the same functionality in any client (asp.net, silverlight, etc).
We do go back and forth occasionally on whether it is appropriate to add the logic to the business object, but there are enough exceptions (i.e. web services, simple collections, etc) that we always end up back at the above design.