asp.net.ph

ListControl.DataValueField Property

System.Web.UI.WebControls Namespace   ListControl Class


Sets or retrieves the field in the data source that provides the Value for each list item.

Syntax


Inline <asp:ListControl datavaluefield = strFieldName ... >
Script ListControl.DataValueField [ = strFieldName ]

Property Value


strFieldName String specifying the field in the data source to bind to the ListItem.Value property of each list option.

The property is read/write with no default value.

Remarks

Use the DataValueField property to specify which field from the DataSource to bind to the Value property of each item in the control.

This differs from the DataTextField property, which is used to specify the field that will provide the Text of each list option. DataTextField provides the selectable options that the user interacts with, while DataValueField provides the values that are used when submitting the form data.

Example

The following example demonstrates how to use the DataValueField property to specify which field from the DataSource is used to provide the values of the option elements in a ListBox control.

<asp:listbox id = "myList" selectionmode=multiple
   runat = "server" datatextfield = "name" datavaluefield = "locale" />

 Show me 

See Also

ListControl Members   DataSource   DataTextField   DataMember Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph