# Custom DataSource

Telerik UI for ASP.NET MVC lets you use the CustomDataSource builder with helpers that support data binding.

The CustomDataSource builder class gives you full control over the [DataSource client-side API options](https://docs.telerik.com/kendo-ui/api/data/datasource) through Razor syntax. It lets you keep Telerik UI helper benefits—for example, generated validation attributes and editors—while still using JavaScript-level DataSource flexibility. You can also use the CustomDataSource builder in advanced scenarios where the regular DataSource builders limit full DataSource customization.

## DataSource and Custom DataSource

Regular DataSource builders apply many default settings. The CustomDataSource builder removes these defaults, so when you declare a DataSource as custom, configure the required settings explicitly.

The following two examples demonstrate a regular Grid AjaxDataSourceBuilder and a CustomDataSource builder.

```Razor HtmlHelper
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.OrderViewModel>()    
    .Name("grid")
    .Columns(columns => {
        columns.Bound(p => p.OrderID).Filterable(false).Width(100);
        columns.Bound(p => p.Freight).Width(100);
        columns.Bound(p => p.OrderDate).Format("{0:MM/dd/yyyy}").Width(140);
        columns.Bound(p => p.ShipName);
        columns.Bound(p => p.ShipCity).Width(150);
    })
    .HtmlAttributes(new { style = "height:430px;" })
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(20)
        .Read(read => read.Action("Orders_Read", "Grid"))
     )
)
```

The following example demonstrates a CustomDataSourceBuilder definition.

```Razor HtmlHelper
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.ProductViewModel>()    
    .Name("Grid")    
    .Columns(columns => {        
        columns.Bound(p => p.ProductName);
        columns.Bound(p => p.UnitPrice).Width(140);
        columns.Bound(p => p.UnitsInStock).Width(140);
        columns.Bound(p => p.Discontinued).Width(100);
    })
    .DataSource(dataSource => dataSource        
        .Custom()         
        .PageSize(20)
        .Schema(schema => schema.Model(m => m.Id(p => p.ProductID)))
        .Transport(transport =>
        {
            transport.Read(read => read.Action("Orders_Read", "Grid"));
        })
    )
)
```

## See Also

* [Custom DataSource for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/html-helpers/datasource/custom-datasource)
* [Grid Server-Side API Reference](https://www.telerik.com/aspnet-mvc/documentation/api/grid)
* [Custom DataSource in Grid for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/grid/custom-datasource)
