Skip to main content
Tab

AutoCompleteBoxPropertiesBase.ValueField Property

Specifies the data source field that contains values for the editor’s items.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v22.2.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue("")]
public string ValueField { get; set; }

Property Value

Type Default Description
String String.Empty

The data source field name.

Remarks

A data bound editor populates its 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 ValueField property to specify a data source’s field from which the item values should be obtained.

If the ValueField property of a data bound combo box is not defined, the control can automatically obtain item values from a data field whose name is “Value”.

Important

The values contained in the ValueField field must be unique.

The ValueField property synchronizes its value with the editor’s ASPxAutoCompleteBoxBase.ValueField property.

Web Forms Example

Run Demo: ASPxComboBox - Cascading Combo Boxes

<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>
var lastCountry = null;
function OnCountryChanged(cmbCountry) {
    if (cmbCity.InCallback())
        lastCountry = cmbCountry.GetValue().toString();
    else
        cmbCity.PerformCallback(cmbCountry.GetValue().toString());
    }
function OnEndCallback(s, e) {
    if (lastCountry) {
        cmbCity.PerformCallback(lastCountry);
        lastCountry = null;
    }
}

MVC Example

View Example: 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()  
See Also