Skip to main content

Data Binding

  • 3 minutes to read

All data-aware DevExpress MVC extensions expose the Bind method, allowing you to easily bind them to a data source (typically, it is a data Model passed from a Controller). There are also some additional methods facilitating data binding to certain declarative data sources. The table below lists data-aware extensions and corresponding available data binding methods.

Data-Aware Extension Name

Method to Bind to Data Model

Declarative Binding Methods

AppointmentRecurrenceForm

AppointmentRecurrenceFormExtension.Bind

-

Chart

ChartControlExtension.Bind

-

CardView

CardViewExtension.Bind

CardViewExtension.BindToCustomData

CardViewExtension.BindToEF

CardViewExtension.BindToLINQ

CardViewExtension.BindToXML

DataView

DataViewExtensionBase.Bind

DataViewExtensionBase.BindToEF

DataViewExtensionBase.BindToLINQ

DataViewExtensionBase.BindToSiteMap

DataViewExtensionBase.BindToXML

DateNavigator

DateNavigatorExtension.Bind

-

Diagram

DiagramExtension.Bind

-

Gantt

GanttExtension.Bind

-

GridView

GridViewExtension.Bind

GridViewExtension.BindToCustomData

GridViewExtension.BindToEF

GridViewExtension.BindToLINQ

GridViewExtension.BindToXML

HtmlEditor

HtmlEditorExtension.Bind

-

ImageGallery

DataViewExtensionBase.Bind

DataViewExtensionBase.BindToEF

DataViewExtensionBase.BindToLINQ

DataViewExtensionBase.BindToSiteMap

DataViewExtensionBase.BindToXML

ImageGalleryExtension.BindToFolder

ImageSlider

ImageSliderExtension.Bind

ImageSliderExtension.BindToFolder

ImageSliderExtension.BindToXML

ImageZoomNavigator

ImageZoomNavigatorExtension.Bind

ImageZoomNavigatorExtension.BindToFolder

ImageZoomNavigatorExtension.BindToXML

FormLayout

FormLayoutExtension.Bind

-

Menu

MenuExtension.Bind

MenuExtension.BindToXML

MenuExtension.BindToSiteMap

NavBar

NavBarExtension.Bind

NavBarExtension.BindToXML

NavBarExtension.BindToSiteMap

PivotGrid

PivotGridExtension.Bind

PivotGridExtension.BindToEF

PivotGridExtension.BindToLINQ

PivotGridExtension.BindToOLAP

PivotCustomization

PivotCustomizationExtension.Bind

PivotCustomizationExtension.BindToOLAP

PopupControl

PopupControlExtension.Bind

PopupControlExtension.BindToSiteMap

PopupControlExtension.BindToXML

PopupMenu

PopupMenuExtension.Bind

PopupControlExtension.BindToSiteMap

PopupMenuExtension.BindToXML

QueryBuilder

QueryBuilderExtension.Bind

-

RatingControl

RatingControlExtension.Bind

-

ReportDesigner

ReportDesignerExtension.Bind

ReportDesignerExtension.BindToUrl

Ribbon

RibbonExtension.Bind

RibbonExtension.BindToSiteMap

RibbonExtension.BindToXML

RichEdit

RichEditExtension.Bind

RichEditExtension.BindToXML

RichEditCustomDocumentProcessor

RichEditCustomDocumentProcessor.Bind

RichEditCustomDocumentProcessor.BindToXML

Scheduler

SchedulerExtension.Bind

-

SchedulerStorageControl

SchedulerStorageControlExtension.Bind

-

TabControl

TabControlExtension.Bind

TabControlExtension.BindToSiteMap

TabControlExtension.BindToXML

TreeList

TreeListExtension.Bind

TreeListExtension.BindToSiteMap

TreeListExtension.BindToVirtualData

TreeListExtension.BindToXML

TreeView

TreeViewExtension.Bind

TreeViewExtension.BindToSiteMap

TreeViewExtension.BindToVirtualData

TreeViewExtension.BindToXML

VerticalGrid

VerticalGridExtension.Bind

VerticalGridExtension.BindToCustomData

VerticalGridExtension.BindToEF

VerticalGridExtension.BindToLINQ

VerticalGridExtension.BindToXML

WebDocumentViewer

WebDocumentViewerExtension.Bind

-

DataEditorExtensions

EditorExtension.Bind

ComboBoxExtension.Bind

TokenBoxExtension.Bind

ListEditors:

CheckBoxListExtension.BindList

ComboBoxExtension.BindList

ListBoxExtension.BindList

RadioButtonListExtension.BindList

TrackBarExtension.BindList

The following code demonstrates how to bind the Chart extension to a Model.

namespace MyProject.Models {
    public class ChartPoint {
        public int X { get; set; }
        public int Y { get; set; }
    }
}
@Html.DevExpress().Chart(settings => {
    settings.Name = "chart";
    settings.Series.Add(s => {
        s.Name = "My Data";
        s.SetDataMembers("X", "Y");
        s.Views().SplineSeriesView(v =>{ });
    });
}).Bind(Model).GetHtml()
using System.Collections.Generic;
using System.Web.Mvc;
using MyProject.Models;

namespace MyProject.Controllers {
    public class HomeController : Controller {
        public ActionResult Index() {
            return View(GetPoints());
        }

        private List<ChartPoint> GetPoints() {
            var m = new List<ChartPoint>();
            m.Add(new ChartPoint { X = 1, Y = 1 });
            m.Add(new ChartPoint { X = 2, Y = 5 });
            m.Add(new ChartPoint { X = 3, Y = 3 });
            m.Add(new ChartPoint { X = 4, Y = 9 });
            m.Add(new ChartPoint { X = 5, Y = 10 });
            return m;
        }
    }
}

For specifics of binding DevExpress MVC data editors (listed in Data Editors Extensions), refer to the Binding Data Editors to Data topic.

See Also