Skip to main content
ID

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DataGridBuilder<T>.DataSource(Func<DataSourceFactory, OptionsOwnerBuilder>) Method

Binds a DataGrid control to data, allows you to configure data access from different sources: API controllers, Razor page handlers, OData services, arrays, and more.

Namespace: DevExtreme.AspNet.Mvc.Builders

Assembly: DevExtreme.AspNet.Core.dll

#Declaration

C#
public DataGridBuilder<T> DataSource(
    Func<DataSourceFactory, OptionsOwnerBuilder> configurator
)

#Parameters

Name Type Description
configurator Func<DataSourceFactory, OptionsOwnerBuilder>

A function that allows you to configure access to data.

#Returns

Type Description
DataGridBuilder<T>

A reference to this instance after the method is called.

#Remarks

To specify a data source, use a lambda expression. The lambda parameter is a DataSourceFactory class instance that provides methods to configure data access from different sources.

The following example demonstrates how to bind a DataGrid control to an API controller:

@(Html.DevExtreme().DataGrid()
    .DataSource(ds => ds.Mvc()
        .Controller("MyDataController")
        .LoadAction("Get")
        .Key("ID")
    )
)
See Also