wwHtmlHelpers::HtmlDropDown

Creates an HTML Drop Down list. The DropDown can be populated from a data source of a cursor, array or collection and by binding an evaluated expression for text and value displays of each list item and you can add an initial first item.

<%= HtmlDropDown("lstCustomers","","TT_Cust",
                "Trim(Company)",
                "Company + [(] + Careof + [)]",
                "","--- Select a Company") %>
HtmlDropDownBox(lcName,lcSelectedValue,
   lcDataSource, lcDataValueField, 
   lcDataTextField, lcAttributes, 
   lcInitialText, lcInitialValue)

Return Value

Html string for a Dropdown list.

Parameters

lcName
The name/id of the listbox

lcSelectedValue
The selected value for the listbox.

On a Postback operation lcSelectedValue is automatically read from Request.Form() if available.

You can override this behavior, and always force the value provided to be used by postfixing with ":FORCED" to the end of the value string. (ie: TRANSFORM(lnSelectedPk) + ":FORCED")

lcDataSource
The data source. Can be:

  • Table/Cursor Alias name as a string

  • Collection as an object The collection can contain single values or objects. Treated like object with array be. If the data is a collection of objects, lcDataValueField and lcDataTextField are applied against the item (ie. Company or Address.Street will resolve to loItem.Company, loItem.Address.Street).

  • One or two dimensional array (passed by Reference @laArray) Two dimensional array should be value and text respectively. One dimensional can be either the single value or an object.

lcDataValueField
A string expression that is evaluated and used for the Value fields in each list item. This is a string such as "lower(email)" that is run against the FoxPro EVALUATE(expr) function.

lcDataTextField
A string expression that is evaluated and used for the display content in each list item. If not specified the same expression as lcDataValueField is used.

lcAttributes
Any extra HTML attributes you want to use on the list.

lcInitialText
Determines the first item displayed in the list for something like "--- Please select ---". If specified the value for the first item is an empty string.

lcInitialValue
The value for that first injected item.

Example

<%= HtmlDropDown("lstCustomers","","TT_Cust",
				"Trim(Company)",
                "Company + [(] + Careof + [)]",
                "","--- Select a Company") %>

<!-- Always explicitly assign lnSelectedPk via :FORCED postfix -->
<%= HtmlDropDown("lstCustomers",
                 TRANS(lnSelectedPk) + ":FORCED",
                 "TT_Cust","Trim(Company)",
                "Company + [(] + Careof + [)]",
                "","--- Select a Company") %>

See also:

Class wwHtmlHelpers

© West Wind Technologies, 1996-2018 • Updated: 03/10/17
Comment or report problem with topic