Search results

Clear the selected item in DropDownList in ASP.NET Core DropDownList control

20 Jan 2022 / 1 minute to read

You can clear the selected item in the below two different ways.

By clicking on the clear icon which is shown in DropDownList element, you can clear the selected item in DropDownList through interaction. By using showClearButton property, you can enable the clear icon in DropDownList element.

Through programmatic you can set null value to anyone of the index, text or value property to clear the selected item in DropDownList.

The following example demonstrate about how to clear the selected item in DropDownList.

Copied to clipboard
<div class="control-wrapper">
    <div id="default" style='padding-top:75px;'>
        <ejs-dropdownlist id="games" dataSource="" placeholder="Select a game" popupHeight="220px">
<ejs-button id="button" content="Null the value"></ejs-button>

    document.getElementById('button').onclick = () => {
        var dropObject = document.getElementById("games").ej2_instances[0];
        dropObject.value = null;
Copied to clipboard
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebApplication1.Models;

namespace WebApplication1.Controllers
    public class DropDownListController : Controller
        public ActionResult tooltip()
   = new string[] { "American Football", "Badminton", "Basketball", "Cricket", "Football", "Golf", "Hockey", "Rugby", "Snooker", "Tennis" };
            return View();