Skip to main content
A newer version of this page is available. .

How to: Bind a Gauge Control to a Data Source

  • 2 minutes to read

This example shows how to bind the ASPxGaugeControl to data. In this example, ASPxComboBox is bound to an XML data source and lists different car models. ASPxGaugeControl displays horsepower (HP) for the selected car model.

ASPxGaugeControl_db

When a user selects a car model from the dropdown list, the grid fires the ASPxClientEdit.ValueChanged event and sends a callback to the server. This callback passes the index of the selected item to the server-side ASPxGaugeControl.CustomCallback event.

In the ASPxGaugeControl.CustomCallback event handler, specify the gauge’s label text and bind the ASPxGaugeControl to data.

using DevExpress.Web.ASPxClasses;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGauges.Base;

protected void ASPxGaugeControl1_CustomCallback(object source, CallbackEventArgsBase e) {
    ListEditItem item = ASPxComboBox1.Items[Convert.ToInt32(e.Parameter)] as ListEditItem;
    ((ICircularGauge)ASPxGaugeControl1.Gauges[0]).Labels["hp"].Text = item.Text;
    ((ICircularGauge)ASPxGaugeControl1.Gauges[0]).Scales[0].Value = (float)Convert.ToInt32(item.Value);
}