AutoCompleteBoxPropertiesBase.TextField Property
Gets or sets the data source field that provides display texts for the editor’s items.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
String | String.Empty | A string value that specifies the name of the data source field from which the editor obtains item texts. |
Remarks
If an editor is data bound (via the AutoCompleteBoxPropertiesBase.DataSourceID or AutoCompleteBoxPropertiesBase.DataSource property), the editor populates its AutoCompleteBoxPropertiesBase.Items collection by retrieving items from the specified data source and obtaining item characteristics (such as the item text, value or displayed image) from specific data fields. Use the TextField property to specify a data source field from which the item text should be obtained.
If the TextField property of a data bound editor is not defined, the control can automatically obtain the item text from a data field named “Text”.
The TextField property is not in effect if the editor is used in multi-column mode.
Note
The TextField property synchronizes its value with the editor’s ASPxAutoCompleteBoxBase.TextField property.
Example
The following example illustrates how to use the TextField property.
Web Forms approach:
Note
For a full example, see the ASPxComboBox - Cascading Combo Boxes demo.
<dx:ASPxComboBox runat="server" ID="CmbCountry" DropDownStyle="DropDownList" IncrementalFilteringMode="StartsWith"
TextField="CountryName" ValueField="CountryName" Width="100%" DataSourceID="CountriesDataSource"
EnableSynchronization="False">
<ClientSideEvents SelectedIndexChanged="function(s, e) { OnCountryChanged(s); }" />
</dx:ASPxComboBox>
MVC approach:
Note
For a full example, refer to MVC ComboBox Extension - Cascading Combo Boxes.
@Html.DevExpress().ComboBox(settings => {
settings.Name = "City";
settings.Properties.TextField = "Name";
settings.Properties.ValueField = "ID";
...
settings.Properties.ClientSideEvents.BeginCallback = "function(s, e) { e.customArgs['Country'] = Country.GetValue(); }";
}).BindList(CS.Models.City.GetCities(Model.Country)).Bind(Model.City).GetHtml()
...
@Html.DevExpress().ComboBox(settings => {
settings.Name = "Country";
settings.Properties.TextField = "Name";
settings.Properties.ValueField = "ID";
...
settings.Properties.ClientSideEvents.SelectedIndexChanged = "function(s, e) { City.PerformCallback(); }";
}).BindList(CS.Models.Country.GetCountries()).Bind(Model.Country).GetHtml()
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the TextField property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.