# Cascade ComboBoxes Using Web API Service

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>ComboBox for Telerik UI for ASP.NET MVC</td>
 </tr>
 <tr>
  <td>Product Version</td>
  <td>Created with version 2024.4.1112</td>
 </tr>
</table>

## Description

How can I implement cascading ASP.NET MVC ComboBoxes that bind to Web API service?

## Solution

The example below relies on the following key steps:

1. Create the Web API service:

```C# Controller
    public class SpecialtyController : ApiController
    {
        // GET api/Specialty
        public IEnumerable<Specialty> Get(int typeId, string filterValue)
        {
            List<Specialty> specialty = new List<Specialty>();

            specialty.Add(new Specialty { Name = "Test" + new Random().Next(1000).ToString(), Value = 1, TypeId = typeId });
            specialty.Add(new Specialty { Name = "Test" + new Random().Next(1000).ToString(), Value = 2, TypeId = typeId });
            specialty.Add(new Specialty { Name = "Test" + new Random().Next(1000).ToString(), Value = 3, TypeId = typeId });
            specialty.Add(new Specialty { Name = "Test" + new Random().Next(1000).ToString(), Value = 4, TypeId = typeId });

            if (!string.IsNullOrWhiteSpace(filterValue))
            {
                specialty = specialty.Where(s => s.Name.StartsWith(filterValue)).ToList();
            }

            return specialty.AsEnumerable();
        }
    }
```

2. Configure the ComboBox for Web API data binding:

```Razor HtmlHelper
@(Html.Kendo().ComboBox()
    .Name("specialty")
    .DataTextField("Name")
    .DataValueField("Value")
    .Filter(FilterType.StartsWith)
    .DataSource(source => source
        .Custom()
        .ServerFiltering(true)
        .Transport(transport => transport
            .Read(read => read
                .Url("/api/Specialty")
                .DataType("json")
                .Data("filterSpecialtyData")
            )
        )
    )
    .Enable(false)
    .AutoBind(false)
    .CascadeFrom("type")
    .CascadeFromField("TypeId")
)

<script>
    function filterSpecialtyData() {
        return {
            typeId: $("#type").val(),
            filterValue: $("#specialty").data("kendoComboBox").input.val()
        }
    }
</script>
```

You can refer to the [ASP.NET MVC application](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master/Telerik.Examples.Mvc/Telerik.Examples.Mvc/Areas/DropDownListWebApi) in the [UI for ASP.NET MVC Examples repository](https://github.com/telerik/ui-for-aspnet-mvc-examples/tree/master) to review the complete example.

## More ASP.NET MVC ComboBox Resources

* [ASP.NET MVC ComboBox Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/combobox/overview)

* [ASP.NET MVC ComboBox Demos](https://demos.telerik.com/aspnet-mvc/combobox)

* [ASP.NET MVC ComboBox Product Page](https://www.telerik.com/aspnet-mvc/combobox)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the ComboBox for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/combobox)

* [Server-Side API Reference of the ComboBox for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/combobox)

* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
