New to Telerik UI for ASP.NET CoreStart a free 30-day trial

Use DropDownList and Custom DataSource to Bind to ToDataSourceResult Output

Environment

ProductDropDownList for Telerik UI for ASP.NET Core
Product VersionCreated with version 2024.4.1112

Description

How can I use a custom DataSource to bind the ASP.NET Core 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. You can use this as a starting point to configure the same behavior in an ASP.NET Core project.

More ASP.NET Core DropDownList Resources

See Also