SelectionList.SelectType Property
Gets or sets the type of UI used to provide a selection UI. Must be of type ListSelectType. The default value is DropDown. This API is obsolete. For information about how to develop ASP.NET mobile applications, see the www.asp.net/mobile Web site.
Assembly: System.Web.Mobile (in System.Web.Mobile.dll)
Property Value
Type: System.Web.UI.MobileControls.ListSelectTypeType of UI used to provide a selection UI.
A SelectionList object can be rendered as a CheckBox, DropDown, ListBox, MultiSelectListBox, or Radio list, depending on the target device. The selection type also affects whether the control allows the user to select multiple items. The MultiSelectListBox and CheckBox settings allow multiple selections; other settings allow only a single selection. The selection types are shown in the following table.
ListSelectType value | Description | Multiselect |
|---|---|---|
CheckBox | Renders list items with check boxes and multiple selection capability. | Yes |
DropDown | Renders list items in a drop-down list box. | No |
ListBox | Renders list items in a list box. | No |
MultipleSelectionListBox | Renders list items in a list box with multiple selection capability. | Yes |
Radio | Renders list items as options. | No |
The following code example shows how to use the SelectedIndexChanged event. It also shows how to use the Rows property on postback to expand the list.
Note |
|---|
The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code sample must be copied into an empty text file that has an .aspx extension. For more information, see ASP.NET Web Forms Page Syntax Overview. |
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <script runat="server"> Public Sub Page_Load(ByVal sender As Object, _ ByVal e As EventArgs) If Not IsPostBack Then ' Create data for the list Dim arr As New ArrayList() arr.Add(New _ Task("Verify transactions", "Done")) arr.Add(New _ Task("Check balance sheet", "Scheduled")) arr.Add(New _ Task("Call customer", "Done")) arr.Add(New _ Task("Issue checks", "Pending")) arr.Add(New _ Task("Send report", "Pending")) arr.Add(New _ Task("Attend meeting", "Scheduled")) ' Set properties for the list SelList1.SelectType = _ ListSelectType.ListBox SelList1.Wrapping = Wrapping.NoWrap SelList1.DataValueField = "Status" SelList1.DataTextField = "TaskName" SelList1.Rows = 3 ' Bind the list to the data SelList1.DataSource = arr SelList1.DataBind () Label1.Text = "Select an item and click the button." Label2.Text = "Tasks are arranged by priority" End If End Sub Private Sub ShowStatus(ByVal sender As Object, ByVal e As EventArgs) Const statusSpec As String = "Status: {0} is {1}" Const prioSpec As String = "Priority: {0}" ' Expand the list to show all items SelList1.Rows = SelList1.Items.Count ' Display the status Label1.Text = String.Format(statusSpec, _ SelList1.Selection.Text, _ SelList1.Selection.Value) ' Display the priority Label2.Text = String.Format(prioSpec, _ (SelList1.SelectedIndex + 1)) End Sub ' Custom class for the task data Class Task Private _TaskName As String Private _Status As String Public Sub New(ByVal TaskName As String, _ ByVal Status As String) _TaskName = TaskName _Status = Status End Sub Public ReadOnly Property TaskName() As String Get Return _TaskName End Get End Property Public ReadOnly Property Status() As String Get Return _Status End Get End Property End Class </script> <html xmlns="http:'www.w3.org/1999/xhtml" > <body> <mobile:Form runat="server" id="Form1"> <mobile:Label runat="server" id="Label1" /> <mobile:Label runat="server" id="Label2" /> <mobile:SelectionList runat="server" id="SelList1" OnSelectedIndexChanged="ShowStatus" /> <mobile:Command ID="Command1" runat="server" Text="Show Status" /> </mobile:Form> </body> </html>
Available since 1.1
SelectionList Class
System.Web.UI.MobileControls Namespace
ASP.NET Data Access Content Map
Introduction to the SelectionList Control
Creating New Controls
Creating Custom Mobile Controls
