MultiSelect
Complex Type
Features
Sample
Description
This sample shows how to bind to a list of complex type using "DisplayMemberPath" , "SelectedValuePath" and "CheckedMemberPath" properties.
Use HeaderPath if you want to decouple the value shown in the header content from the values shown in the drop-down list.
Source
ComplexTypeController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity.Validation;
using System.Data;
using C1.Web.Mvc;
using C1.Web.Mvc.Serialization;
using MvcExplorer.Models;
namespace MvcExplorer.Controllers
{
public partial class MultiSelectController : Controller
{
private C1NWindEntities db = new C1NWindEntities();
public ActionResult ComplexType()
{
return View(db);
}
}
}
ComplexType.cshtml
@model C1NWindEntities
<div>
<label>@Html.Raw(Resources.MultiSelect.ComplexType_Text0)</label>
@(Html.C1().MultiSelect()
.Bind(Model.Products)
.Name("products")
.HeaderPath("ProductName")
.DisplayMemberPath("ProductName")
.SelectedValuePath("ProductID")
.CheckedMemberPath("Discontinued")
)
</div>
@section Description{
<p>@Html.Raw(Resources.MultiSelect.ComplexType_Text1)</p>
<p>@Html.Raw(Resources.MultiSelect.ComplexType_Text2)</p>
}
Documentation