asp.net.ph

ListControl.DataTextField Property

System.Web.UI.WebControls Namespace   ListControl Class


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

Syntax


Inline <asp:ListControl datatextfield = strFieldName ... >
Script ListControl.DataTextField [ = strFieldName ]

Property Value


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

The property is read/write with no default value.

Remarks

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

This differs from the DataValueField property, which is used to specify the field that will provide the Value of each select 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 examples demonstrate using the DataTextField property in different scenarios, to specify which field from the DataSource is used to populate the option elements in controls that derive from the ListControl.

Navigating thru the Rows of a DataTable
Run Sample | View Source
Binding a BulletedList to a Data Source Control
Run Sample | View Source
Using a DropDownList in an Editable DataList
Run Sample | View Source
See Also

ListControl Members   DataTextFormatString   DataSource   DataValueField   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