The ListControl Family of Controls

\QCubed\Control\ListControl controls handle simple lists of objects which can be selected. In its most basic form, we are talking about HTML listboxes (e.g. <select>) with name/value pairs (e.g. <option>).

Of course, listboxes can be single- and multiple-select. But note that sometimes, you may want to display this list as a list of labeled checkboxes (which basically acts like a multiple-select listbox) or a list of labeled radio buttons (which acts like a single-select listbox). QCubed includes the ListBox, CheckboxList and RadioButtonList controls which all inherit from ListControl to allow you to present the data and functionality that you need to in the most user-friendly way possible.

In this example we create a ListBox and Checkbox control. They pull their data from the Person table in the database. Also, if you select a person, we will update the lblMessage label to show what you have selected.

If you do a View Source... in your browser to view the HTML, you'll note that the value attributes in the <option> tags are indexes (starting with 0) and not the values assigned in the PHP code. This is done intentionally as a security measure to prevent database indexes from being sent to the browser, and to allow for non-string based values, or even duplicate values. You can lookup specific values in the ListControl by using the SelectedValue attribute. You can also lookup selected Names, Ids, and get the whole ListItem.

Recently Selected: <None>