SelectionLists and Index Values

As much as possible, the SelectionList ASP.NET mobile control emits very concise markup language to the client browser. For the most part, it does not send the contents of the item's Value property to the client. Instead, it sends a zero-based index number for the item.

For example, suppose a SelectionList control with the identifier MySelectionList contains the item property values in the following table.

Text Value
Rain "A rainy string"
Snow "A snowy string"
Sun "A sunny string"
Wind "A windy string"

A portion of the markup language that the control emits to the client browser would resemble the following.

<Select Name = "MySelectionList">
   <Option Value = "0">Rain</Option>
   <Option Value = "1">Snow</Option>
   <Option Value = "2">Sun</Option>
   <Option Value = "3">Wind</Option>
<Select>

When the user chooses an item in the list and the client browser posts the form back to the server, the client sends the index number of the selected item. If, using the previous example, the user selects Snow and the client posts the form, the client will send the number 1 back to the server.

Because the strings in the items' Value properties are not being passed between the client and the server, communication proceeds more efficiently. This technique is especially helpful for narrow-bandwidth wireless channels.

It is possible that the client does not post the user's input back to the same page. This occurs when the Action property of the Form control that contains the SelectionList control is set to the URL of another page. In that case, the SelectionList control does not try to optimize its output. Instead of sending index numbers to the client, it sends the actual strings contained in each item's Value property.

See Also

Accessing Data Using Listing Controls