ComponentOne ComboBox for ASP.NET: ComboBox for ASP.NET AJAX Quick Start > Step 2 of 4: Binding C1ComboBox to a Data Source

Step 2 of 4: Binding C1ComboBox to a Data Source

In this topic, you will bind C1ComboBox to a data source, C1ListDemo.mdb. The C1ListDemo.mdb file is installed by default in the C:\Documents and Settings\<username>\My Documents\ComponentOne Samples\Common (Windows XP) or C:\Users\<username>\Documents\ComponentOne Samples\Common (Windows 7/Vista) folder. First, we will add the data source to the project, and then we can bind it to C1ComboBox.

1.   In the Solution Explorer, right-click the App_Data folder, and then click Add Existing Item.

2.   Locate the C1ListDemo.mdb file.

3.   In the Add Existing Item dialog box, click the C1ListDemo.mdb file, and then click Add.

4.   Go back to the Default.aspx page.

5.   Select the C1ComboBox control, and click the Smart Tag to open the C1ComboBox Tasks menu.

6.   Click the Choose Data Source drop-down arrow and select <New data source>.

7.   In the Data Source Configuration Wizard, select Access Database and click OK.

8.   Click Browse and select App_Data under Project folders in the Select Microsoft Access Database dialog box.

9.   Choose C1ListDemo.mdb in the Contents of folder pane on the right-hand side and click OK.

10.  Click Next. The Configure the Select Statement window appears.

a.   Confirm that the Specify columns from a table or view option is selected.

b.   In the Name drop-down list, select Customer.

c.    In the Columns box, select UserCode, LastName, and FirstName or any other desired check boxes.

11.  Click Next. The Test Query page appears. Optionally, click Test Query to test your query.

12.  Click Finish to close the wizard and add the data source.

13.  Click the smart tag again to open the C1ComboBox Tasks menu.

14.  Click the drop-down arrow next to the DataTextField property and select LastName.

The C1ComboBox control is now bound to the C1ListDemo.mdb data source. Customers' last names will appear in the drop-down list of the C1ComboBox control. In the next step, you will customize the C1ComboBox control by enabling auto completion, making it resizable, setting the visual style, and setting the selection mode to Multiple so users can choose multiple items from the C1ComboBox drop-down list.


Send comments about this topic to ComponentOne.
Copyright © 1987-2010 ComponentOne LLC. All rights reserved.