Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Databinding and the Validating event

I have always assumed that databinding adds the handler to a edit controls Changed event so it can change the bound source.  Wrong.  It does this only so it can update any other controls bound to the same source. 

The source does not change until the edit control's Validating event fires.  Databinding is actually hooked to the Validating event which is driven by a change in focus.

I discovered this by trying to programmatically set a Textboxes text property to "". The text box displayed "", however I never saw the source change.   After some probing, I discovered the source does not change until the controls Validating event fires.  This actually makes sense now.  The source should not change until the data is valid.  Good to know.

 

1 Comment

Comments have been disabled for this content.