Skip to content

Auto-bind an individual control to its bound object

AutoBindControlAncestor.DataBind()/BindToControl()/BindToObject() implement the reflection-based binding contract shared by AutoBindTextbox, AutoBindWebDateTimeEdit, and AutoBindWebMaskEdit. The control resolves its bound business-object property via a dotted-path lookup (BindSource), pushes the value into its own Value property, and — on user postback — writes edits back onto the bound object.

Field Value
Operation ID OP-AJAX-002
Trigger ASP.NET control lifecycle calling DataBind() on the control (directly, or via Page-wide auto-bind and validate); or a user postback event (TextChanged/ValueChange)
Inputs RootBindingObject, BindSource (dotted property path, e.g. "Submission.Locations.Primary"), BindProperty
Outputs Control's Value populated from the bound business-object property; on postback, the bound object's property is updated
Primary components AutoBindControlAncestor.DataBind, AutoBindControlAncestor.BindToControl, AutoBindControlAncestor.BindToObject, BindingUtility.GetObject, BindingUtility.BindValue
Entry point SAIF.Presentation.Web.Controls.AJAX.Infragistics103\AutoBindControlAncestor.vb

Steps

  1. MyBase.DataBind() runs standard CompositeControl data binding.
  2. If RootBindingObject is Nothing, the method returns immediately — binding silently no-ops.
  3. BindToControl() is called: BindingUtility.BindValue(BoundObject, BindProperty, Me, "Value") reads the named property off the resolved BoundObject (itself resolved via BindingUtility.GetObject(RootBindingObject, BindSource), a dotted-path traversal) and pushes it into the control's Value property via reflection (PropertyInfo.SetValue).
  4. If AutoValidateOnDataBind is True (default), Validate a bound control and reflect state is invoked.
  5. Concrete subclasses (e.g., AutoBindTextbox.LayoutControls) subsequently push Value into the underlying HTML/Infragistics editor control (m_Textbox.Text = CStr(Value), etc.) at render time.
  6. On user postback (Textbox_TextChanged/equivalent ValueChange handlers), the control's Value is updated from the editor, then BindToObject() is called: BindingUtility.BindValue(Me, "Value", BoundObject, BindProperty) writes the new value back onto the bound business object.
  7. If AutoValidate is True, Validate a bound control and reflect state runs again.

No SQL/table interaction occurs directly in this operation; it operates purely against in-memory business objects already loaded by the BOF layer.

Process flow

The following diagram visualizes this operation's control flow.

flowchart TD
    Start([Control lifecycle calls DataBind]) --> Check{RootBindingObject is Nothing?}
    Check -->|Yes| EndNoOp([No-op, return])
    Check -->|No| Bind[BindToControl reads BoundObject property into Value]
    Bind --> AutoVal{AutoValidateOnDataBind?}
    AutoVal -->|Yes| Val[Validate control]
    AutoVal -->|No| Render[Render editor with Value]
    Val --> Render
    Render --> Postback([User edits and posts back])
    Postback --> WriteBack[BindToObject writes Value back onto BoundObject]
    WriteBack --> AutoVal2{AutoValidate?}
    AutoVal2 -->|Yes| Val2[Validate control]
    AutoVal2 -->|No| EndOk([Done])

Failure and edge-case behavior

  • RootBindingObject Is Nothing: DataBind() returns immediately without binding the control.
  • BindingUtility.GetObjectValue/SetObjectValue/BindValue swallow NotSupportedException internally (e.g., for reflection failures on unsupported property types) — the bind silently fails rather than throwing.

Sources

  • SAIF.Presentation.Web.Controls.AJAX.Infragistics103\AutoBindControlAncestor.vb
  • SAIF.Presentation.Web.Controls.AJAX.Infragistics103\BindingUtility.vb
  • SAIF.Presentation.Web.Controls.AJAX.Infragistics103\AutoBindTextbox.vb
  • SAIF.Presentation.Web.Controls.AJAX.Infragistics103\AutoBindWebDateTimeEdit.vb
  • SAIF.Presentation.Web.Controls.AJAX.Infragistics103\AutoBindWebMaskEdit.vb