Defining a Datasource

There are two steps to defining a datasource with Combo.

  1. Set up the HTML combo tag to specify your datasource.
  2. Specify a data handler (AKA getHandler).

Set up the HTML Combo Tag for your Datasource

In the HTML page containing your Combobox, you need to write out the tag with the search mode, the datasource, and a few other details. The combo tag is described in more detail in another article.

The first thing to do is set what search mode you are using. These are Filter, Classic, SmartSearch, SmartList, and Unbound. Only Unbound does not require a seperate datasource. You do this in the top-level Combo tag.

Next, you define your list object and the attribute DatasourceUrl, which is your remote datasource (or getHandler). This is similar to the getHandler in the EBA Grid Control.

eg:

<ntb:Combo id="myCombo" Mode="classic">
  <ntb:ComboTextBox DataFieldIndex="0"></ntb:ComboTextBox>
    <ntb:ComboList DatasourceUrl="get.asp" PageSize="12">
    </ntb:ComboList>
</ntb:Combo>

Specify a Data Handler (getHandler)

Typically a getHandler is a seperate file that does the database connection, and outputs a raw XML stream which is read by the combobox. The EBA combobox does a background HTTP request to this page and expects to see this XML page. If it doesn"t, your combobox will be empty, or you will see "undefined" in the list.

Unbound Mode

In unbound mode you don"t specify a getHandler. You merely contain your values inside the combobox tag as you would with a regular Listbox control.

eg:

<ntb:Combo id="mycombo" Mode="unbound">
 <ntb:ComboTextBox DataFieldIndex="0"></ntb:ComboTextBox>
 <ntb:ComboList>
 <ntb:ComboColumnDefinition DataFieldIndex="0"></ntb:ComboColumnDefinition>
 <ntb:ComboColumnDefinition DataFieldIndex="1"></ntb:ComboColumnDefinition>
</ntb:ComboList>  <ntb:ComboValues fields="City|Population">
     <ntb:ComboValue a="Vancouver" b="3,000,000" />
     <ntb:ComboValue a="Toronto" b="4,500,000" />
     <ntb:ComboValue a="Ottawa" b="1,000,000" />
     <ntb:ComboValue a="California" b="4,500,000" />
     <ntb:ComboValue a="Halifax" b="900,000" />
     <ntb:ComboValue a="Calgary" b="1,500,000" />
     <ntb:ComboValue a="Red Deer" b="100,000" />
     <ntb:ComboValue a="Prince George" b="200,000" />
     <ntb:ComboValue a="Portland" b="1,500,000" />
     <ntb:ComboValue a="Atlanta" b="4,500,000" />
  </ntb:ComboValues>
</ntb:Combo>

This unbound combobox has two columns and no column labels. In unbound mode the list values follow an XML convention a,b,c,d, .. etc. The Fields attribute must be defined, which give labels to each data column. For those unfamiliar with XML, in this example, City is column a, and Population is column b.

If you would like to know more about using Combo with unbound data, there is another article in this knowledgebase under developement which covers it.

Bound Modes (Filter, Classic, SmartSearch, SmartList, Compact)

For these modes, we must define a URL that specifies where to retrieve XML from. This getHandler should respond to certain querystring variables. See the article entitled "Constructing SQL Queries for Web Combo V3" for a full description of these parameters.

If our getHandler is get.asp, and our desired search mode was Classic, our combo tag might look like this:

<ntb:Combo id="cmbCustomers" Mode="classic">
  <ntb:ComboTextBox DataFieldIndex="0"></ntb:ComboTextBox>
  <ntb:ComboList DatasourceUrl="get.asp" PageSize="12">
    <ntb:ComboColumnDefinition DataFieldIndex="0">
    </ntb:ComboColumnDefinition>
    <ntb:ComboColumnDefinition DataFieldIndex="1">
    </ntb:ComboColumnDefinition>
  </ntb:ComboList>
</ntb:Combo>

In this example we have two columns and have set our getHandler to "get.asp" and our page size (the number of records to retrieve at a time) to 12.

Please see our article about using a Combo getHandler for setting up your getHandler.

page_revision: 3, last_edited: 1224630041|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License