Bind and render a drop-down list¶
Support enum-sourced binding and a read-only rendering mode for the drop-down. Host page calls DataBind, or the ASP.NET page lifecycle invokes Render.
| Field | Value |
|---|---|
| Operation ID | OP-V2-005 |
| Trigger | Host page calls DataBind, or the ASP.NET page lifecycle invokes Render. |
| Inputs | EnumDatasource, MapUnderscore, ReadOnly, ValueText, control width/style. |
| Outputs | Populated list items on bind; interactive drop-down or read-only textbox markup on render. |
| Primary components | SAIFDropDownList |
| Entry point | SAIF.Presentation.Web.Controls.V2/SAIFDropDownList.vb |
Steps¶
- On
DataBind, ifEnumDatasourceis set, read the enum member names viaSystem.Enum.GetNames. (BR-V2-027) - If
MapUnderscoreis true, replace_with a space in every name before assigning them as the baseDataSource. (BR-V2-028) - Call the base
DataBind. (BR-V2-029) - On
Render, whenReadOnlyis true, create a read-onlyTextBoxwith CSS classdisabledbackcolor, width reduced by 5 pixels when the control width is 5 or greater, and text taken from the selected item — or fromValueTextwhen the selected value is blank. (BR-V2-030, BR-V2-031, BR-V2-032, BR-V2-033) - When not read-only and
Visible, call the baseRender. (BR-V2-034, BR-V2-035) - On failure: clear the selection and re-render once.
SelectedItemAsEnumconverts between selected item text and enum value, reversing the underscore mapping. (BR-V2-036)
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([DataBind]) --> E{EnumDatasource set?}
E -->|Yes| Names[GetNames + optional underscore mapping]
Names --> Base[MyBase.DataBind]
E -->|No| Base
Base --> RenderStart([Render])
RenderStart --> RO{ReadOnly?}
RO -->|Yes| Text[Substitute read-only TextBox]
RO -->|No| Vis{Visible?}
Vis -->|Yes| BR[MyBase.Render]
BR -->|Throws| Retry[Clear selection, retry once]
Vis -->|No| NoOut([No output])
Failure and edge-case behavior¶
- On failure: clear the selection and re-render once.
Related documentation¶
Sources¶
SAIF.Presentation.Web.Controls.V2/SAIFDropDownList.vb