New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Use DropDownList and Custom DataSource to Bind to ToDataSourceResult Output
Environment
Product | DropDownList for Telerik UI for ASP.NET MVC |
Product Version | Created with version 2024.4.1112 |
Description
How can I use a custom DataSource to bind the ASP.NET MVC DropDownList component to the ToDataSourceResult
output?
Solution
You can implement this scenario using the following DropDownList definition:
Razor
@(Html.Kendo().DropDownList()
.Name("productDropDownList")
// The "DataTextField" and "DataValueField" options are not set, because the component is bound to an array of strings.
.DataSource(source =>
{
source.Custom()
.Type("aspnetmvc-ajax")
.Transport(transport =>
{
transport.Read("_GetData", "Home");
})
.Schema(schema =>
{
schema.Data("Data")
.Total("Total");
});
})
)
To see the complete implementation, refer to the ASP.NET MVC application on how to use a custom DataSource to bind the DropDownList to a ToDataSourceResult
output.