SelectionList 是 ASP.NET 行動控件套件中的核心列表控件,支援下拉選單、清單方塊、單選/多選按鈕等多種呈現模式,適應不同行動裝置瀏覽器特性。
<mobile:SelectionList
runat="server"
id="id"
Alignment="{NotSet|Left|Center|Right}"
BackColor="backgroundColor"
BreakAfter="{True|False}"
Font-Bold="{NotSet|False|True}"
Font-Italic="{NotSet|False|True}"
Font-Name="fontName"
Font-Size="{NotSet|Normal|Small|Large}"
ForeColor="foregroundColor"
StyleReference="StyleReference"
Wrapping="{NotSet|Wrap|NoWrap}"
DataMember="dataMember"
DataSource="dataSource"
DataTextField="DataTextField"
DataValueField="DataValueField"
SelectType="{DropDown|ListBox|Radio|MultiSelectListBox|CheckBox}"
Title="String"
OnItemDataBind="itemDataBindHandler"
OnSelectedIndexChanged="selectedIndexChangedHandler">
<Item Text="Text" Value="Value" Selected="{True|False}" />
</mobile:SelectionList>
<Item> 標籤,Text 顯示文字,Value 隱藏值,Selected 預選狀態DataSource、DataTextField、DataValueField,可選 DataMember 指定 DataTable| 屬性/事件 | 型別 | 說明 |
|---|---|---|
| DataSource | Object | 資料來源(DataSet、集合等) |
| DataTextField | String | 顯示欄位名稱 |
| DataValueField | String | 隱藏值欄位名稱 |
| Items | MobileListItemCollection | 所有列表項目集合,可程式碼操作 |
| Rows | Integer | ListBox/MultiSelectListBox 可見行數 |
| SelectedIndex | Integer | 目前選中項目索引(多選時回傳第一個) |
| Selection | MobileListItem | 目前選中項目物件,無選擇回傳 null |
| SelectType | ListSelectType | 呈現模式:DropDown/ListBox/Radio/MultiSelectListBox/CheckBox |
| ItemDataBind | Event | 資料繫結時每項觸發 |
| SelectedIndexChanged | Event | 單選模式下選項改變觸發,需 Command 控件回傳 |
SelectionList 本身不會自動回傳,必須搭配 Command 控件(如 Button)在同一 Form 內,使用者操作後點擊按鈕觸發回傳,ASP.NET 執行階段才更新 SelectedIndex 等屬性並觸發 SelectedIndexChanged 事件。
WML 瀏覽器不支援多行顯示,Rows 屬性無效。