The MultiSelect control can be customized to display a list of custom objects in the dropdown. This is accomplished by by binding it with a collection of objects using DisplayMemberPath, SelectedValuePath, and CheckedMemberPath properties.
The following image shows a MultiSelect control bound to a collection of Products from a local NorthWind database file C1NWind.mdf.
The following code examples demonstrate how to bind a Multi-select control to a collection of objects:
ComplexTypeController.cs
C# |
Copy Code
|
---|---|
private C1NWindEntities db = new C1NWindEntities(); public ActionResult ComplexType() { return View(db); } |
ComplexType.cshtml
HTML |
Copy Code
|
---|---|
@model C1NWindEntities <div> <label>MultiSelect bound to an array of objects:</label> <c1-multi-select display-member-path="ProductName" selected-value-path="ProductID" checked-member-path="Discontinued"> <c1-items-source source-collection="Model.Products" /> </c1-multi-select> </div> |