Bagikan melalui


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, ASP.NET 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 contains items with text and value settings listed in the following table.

Item Text

Item Value

Rain

"A rainy string"

Snow

"A snowy string"

Sun

"A sunny string"

Wind

"A windy string"

A portion of the markup that the control renders would resemble the following:

<Select Name = " WeatherSelectionList">
   <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 browser posts the form to the server, the client sends the index number of the selected item. If the user selects Snow, the client sends the number 1 to the server.

Because the strings in the items' Value properties are not being passed between the client and the server, communication is more efficient. 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

Concepts

Accessing Data Using Listing Controls