Local Binding
The Telerik UI ListBox for ASP.NET Core enables you to bind it to local arrays of data.
When you use complex data objects, use the DataTextField
and DataValueField
properties to notify the ListBox about your preferred binding behavior.
@(Html.Kendo().ListBox()
.Name("optional")
.Toolbar(toolbar =>
{
toolbar.Position(ListBoxToolbarPosition.Right);
toolbar.Tools(tools => tools
.MoveUp()
.MoveDown()
.TransferTo()
.TransferFrom()
.TransferAllTo()
.TransferAllFrom()
.Remove()
);
})
.ConnectWith("selected")
.BindTo(ViewBag.Attendees) // Bind the ListBox to a collection
)
@(Html.Kendo().ListBox()
.Name("selected")
.BindTo(new List<string>())
.Selectable(ListBoxSelectable.Multiple)
)
using System;
using System.Collections.Generic;
using System.Linq;
using Kendo.Mvc.Examples.Models;
using Microsoft.AspNetCore.Mvc;
namespace Kendo.Mvc.Examples.Controllers
{
public partial class ListBoxController : BaseController
{
public IActionResult Index()
{
ViewBag.Attendees = new List<string>
{
"Steven White",
"Nancy King",
"Nancy Davolio",
"Robert Davolio",
"Michael Leverling",
"Andrew Callahan",
"Michael Suyama"
};
return View();
}
}
}