Search results

Add Items in ASP.NET Core ListBox control

18 Oct 2021 / 1 minute to read

To add an item or multiple items, addItems method can be used. In the following example, the Bugatti Veyron Super Sport and SSC Ultimate Aero items will be added while clicking Add Items button.

Copied to clipboard
<ejs-listbox id="listbox" dataSource=""></ejs-listbox>
<button class="e-btn" id="additem">Add Items</button>

    document.getElementById('additem').onclick = function () {
        var items = ['Bugatti Veyron Super Sport', 'SSC Ultimate Aero'];
        var listboxobj = ej.base.getInstance(document.getElementById('listbox'), ejs.dropdowns.ListBox)
        if (!listboxobj.getDataByValue('Bugatti Veyron Super Sport')) {
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 ListBoxController : Controller
        public IActionResult additem()
   = new string[] { "BadmHennessey Venominton", "Bugatti Chiron", "Koenigsegg CCR", "McLaren F1", "Aston Martin One- 77", "Jaguar XJ220" };
            return View();