MultiAutoComplete
MultiAutoComplete
Complex Type
This sample shows how to bind to a list of complex type using "DisplayMemberPath" and "SelectedValuePath".
Features
Description
This sample shows how to bind to a list of complex type using "DisplayMemberPath" and "SelectedValuePath".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Web; using System.Web.Mvc; using MvcExplorer.Models; namespace MvcExplorer.Controllers { partial class MultiAutoCompleteController { public ActionResult ComplexType() { var list = GetSystemColors(); return View(list); } private static NamedColor[] GetSystemColors() { return Enum.GetValues( typeof (KnownColor)) .Cast<KnownColor>() .Select(c => new NamedColor { Name = c.ToString(), Value = "#" + Color.FromKnownColor(c).ToArgb().ToString( "X8" ).Substring(2) }) .ToArray(); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @model IEnumerable< MvcExplorer.Models.NamedColor > < div > < label > @Html .Raw(Resources.MultiAutoComplete.ComplexType_Text1)</ label > < p > @Html .Raw(Resources.MultiAutoComplete.ComplexType_Text0)</ p > @ (Html.C1().MultiAutoComplete() .Bind(Model) .DisplayMemberPath( "Name" ) .SelectedIndexes(0,1) ) </ div > @section Description{ @Html .Raw(Resources.MultiAutoComplete.ComplexType_Text2) } |