devxlogo

Dynamically bind a DataList or DataCombo control to an ADO Recordset

Dynamically bind a DataList or DataCombo control to an ADO Recordset

When dynamically changing the bound ADORecordset for a DataCombo or DataList control, the order you follow when assigning the properties is important. This is the correct sequence of operations to perform to change the bound recordset for these controls:

' unbind the current sourcesSet DataCombo1.DataSource = NothingSet DataCombo1.RowSource = Nothing' set the new binding - start with the string propertiesDataCombo1.DataField = "ProductID"    ' the bound field in master tableDataCombo1.BoundColumn = "ID"         ' the bound field in detail tableDataCombo1.ListField = "ProductName"  ' the display field in detail tableSet DataCombo1.RowSource = rsProducts ' the detail tableSet DataCombo1.DataSource = rsOrder   ' the master table

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist