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, the ASPxComboBox is bound to an XML data source and lists different car models. The ASPxGaugeControl displays HP for the selected car model.


After an end-user has selected a car model from the dropdown list, the ASPxClientEdit.ValueChanged event is handled to send a callback to the server and generate the server-side ASPxGaugeControl.CustomCallback event, passing it the index of the selected item.

The ASPxGaugeControl.CustomCallback event is handled to specify the gauge label's 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);