Share via


SelectType Property

Sets or returns the type of UI used to provide a selection UI. Must be of type ListSelectType. The default value is DropDown.

public System.Web.UI.MobileControls.ListSelectType SelectType {
   get,
   set
}

Remarks

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 Description Multiselect
CheckBox Render list items with check boxes and multiple selection capability. Y
DropDown Renders list items in a drop-down list box.  
ListBox Renders list items in a list box.  
MultipleSelectionListBox Renders list items in a list box with multiple selection capability. Y
Radio Renders list items as options.  

Example

The following example demonstrates how to use the SelectType property to change the value on the button click postback.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
 
If Not IsPostBack Then
   ' Set the value of the SelectType property.
   SelectionList1.SelectType = ListSelectType.Radio
Else
   SelectionList1.SelectType = ListSelectType.CheckBox
   If SelectionList1.SelectedIndex = - 1 Then
      Label1.Text = "No items selected"
   End If
End If

End Sub

[C#]

public void Page_Load(Object sender, EventArgs e)
{
   if (!IsPostBack)
   {
      // Set the value of the SelectType property.
      SelectionList1.SelectType = ListSelectType.Radio;
   }
   else
   {
      SelectionList1.SelectType = ListSelectType.CheckBox;
      if (SelectionList1.SelectedIndex == -1)
      {
        Label1.Text = "No items selected";
      }
   }
}

See Also

Applies to: SelectionList Class