Hi all
I am using object model as datasource, and I am currently implemented IDataErrorInfo in the model to provide grid validation, but I don't like this. I want to keep my model as pure data model as possible without any logic (validation is type of business logic).
I am looking for other validation optionals.
BR
Bryan
Hi Bryan,
You could do your validation in the grid. There are a lot of events you could use, depending on your needs.
You could use BeforeExitEditMode, BeforeCellUpdate, or BeforeRowUpdate, for example.
Another option would be to use the UltraValidator component.
Personally, I think it makes sense to do validation on the data source itself in many cases. The advantage of doing it that way is that if your UI changes, your validation does not have to change.
Mike Saltzman"] Personally, I think it makes sense to do validation on the data source itself in many cases. The advantage of doing it that way is that if your UI changes, your validation does not have to change.
Thanks Mike, do you mean you prefer to implment IDataErrorInfo in the object model?
I don't know what your application requirements are, so I was just speaking generally. Perhaps you have a good reason for wanting to do validation on the grid and not on the data source.
It just seems to me that if you have some kind of constraint on your data and you want to make sure that constraint it never violated, then the best place to do it is on the data source itself. For example, if a field cannot be null, it doesn't matter to you whether the user enters that field in a grid or via a text box or whatever - it should never be null.
IDataErrorInfo is really designed to notify a user that there is a problem. It doesn't really stop a user from entering invalid data. So no, that wasn't really what I was thinking of, but on the other hand, you could use that if you just want to notify the user their data is invalid without preventing them from entering invalid data.