# Removing DropDownList Items

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Telerik UI for ASP.NET MVC DropDownList</td>
 </tr>
 <tr>
  <td>Progress Telerik UI for ASP.NET MVC version</td>
  <td>Created with the 2022.2.802 version</td>
 </tr>
</table>

## Description

How can I remove items from the Telerik UI for ASP.NET MVC DropDownList?

## Solution

To achieve the desired scenario:

1. Create a `button` that will be responsible for removing an item in the DropDownList.
2. To remove an item, handle `click` event of the previously created button and use the [`.remove()`](https://docs.telerik.com/kendo-ui/api/data/datasource/methods/remove) configuration method of the DropDownList's DataSource.

```Razor Index.cshtml
    <button class="k-button k-button-primary" id="remove">Remove Items</button>

    @(Html.Kendo().DropDownList()
         .Name("color")
         .DataTextField("Text")
         .DataValueField("Value")
         .BindTo(new List<SelectListItem>() {
             new SelectListItem() {
                 Text = "Black",
                 Value = "1"
             },
             new SelectListItem() {
                 Text = "Orange",
                 Value = "2"
             },
             new SelectListItem() {
                 Text = "Grey",
                 Value = "3"
             }
         })
         .Value("1")
         .HtmlAttributes(new { style = "width: 100%" })
    )
```

```JS script.js
    <script>
        $("#remove").click(function() {
           var ddl =  $("#color").data("kendoDropDownList"); // Get the reference of the DropDownList.

           var oldData = ddl.dataSource.data(); // Get the DataSource's data.

           ddl.dataSource.remove(oldData[0]); // Remove the first item.
           ddl.dataSource.remove(oldData[oldData.length - 1]); // Remove the last item.
        });
    </script>
```

For the complete implementation of the suggested approach, refer to the [Telerik REPL example on removing Telerik UI for ASP.NET MVC DropDownList items](https://netcorerepl.telerik.com/QQOXbxbx53N2swP026).

## More ASP.NET MVC DropDownList Resources

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

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

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

* [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

* [Telerik REPL: Removing Telerik UI for ASP.NET MVC DropDownList Items](https://netcorerepl.telerik.com/QQOXbxbx53N2swP026)
* [Client-Side API Reference of the DropDownList for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/dropdownlist)
* [Server-Side API Reference of the DropDownList for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/dropdownlist)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
