Easy Tutorial
❮ Prop Webcontrol Panel Direction Prop Webcontrol Calendar Cellpadding ❯

ASP.NET Web Forms - SortedList Object


The SortedList object combines the features of the ArrayList object and the Hashtable object.


Try It Yourself - Examples

SortedList RadiobuttonList 1

SortedList RadiobuttonList 2

SortedList DropDownList


SortedList Object

The SortedList object contains items represented as key/value pairs. The SortedList object automatically sorts items alphabetically or numerically.

Add items to the SortedList using the Add() method. Adjust the SortedList to its final size using the TrimToSize() method.

The following code creates a SortedList object named mycountries and adds four elements:


Data Binding

The SortedList object can automatically generate text and values for the following controls:

To bind data to a RadioButtonList control, first create a RadioButtonList control in the .aspx page (without any asp:ListItem elements):

Then add the script to create the list and bind the values from the list to the RadioButtonList control:

Next, add a subroutine that will be executed when the user clicks an item in the RadioButtonList control. When a radio button is clicked, a line of text will appear in the label:

Examples

❮ Prop Webcontrol Panel Direction Prop Webcontrol Calendar Cellpadding ❯