Implementing Two-Way Control Binding for Web Forms : Page 6
ASP.NET's native data binding provides only one-way data binding. With a little bit of effort, it's possible to extend the native functionality and provide flexible two-way data binding and a few other simple enhancements that drastically reduce the amount of code you have to write for binding data to controls.
by Rick Strahl
Dec 1, 2003
Page 6 of 7
This next method creates an array of BindingErrorobjects containing information about the error. You can configure custom binding error messages by setting a binding error message on the control (see Figure 4). Otherwise, the code in Listing 7 assigns a generic error message to the property.
Reflection makes it possible to dynamically read and assign property values that were assigned at design time. You can think of it as a simple evaluation mechanism.
This array of binding errors, if any, is returned from the Unbind operation. A couple of helper methods exist to turn the array into HTML. The code for the Inventory example you saw earlier looks something like this:
BindingError Errors =
if (Errors != null)
In addition, each of the controls contains some custom code to display error information, as shown in Figure 5.