我有一个MVC4项目。我正在使用选择列表与optgroup。下面的剃刀代码,
<select name="filters" id="searchable" multiple="multiple">
@foreach (var item in Model.FCategories)
{
<optgroup label="@item.FilterCategoryName">
@{
var item1 = item;
}
@foreach (var filtre in Model.Filters.Where(m => m.FilterCategoryID == item1.FilterCategoryID))
{
<option value="@filtre.FilterID">@filtre.FilterName</option>
}
</optgroup>
}
</select>
我的模特就像这样,
[Required(ErrorMessage = "Boş Olamaz")]
public string Name { get; set; }
[Required(ErrorMessage = "Boş Olamaz")]
public string Seo { get; set; }
public IEnumerable<Filter> Filters { get; set; }
public IEnumerable<FCategory> FCategories { get; set; }
我看到int的过滤值?但我看不到optgroup的价值....我的控制器如下所示;
public ActionResult AddToCategory()
{
var fcat = _otherRepository.GetFCategories().ToList();
var filter = _otherRepository.GetFilters().ToList();
var modelim = new AdminCategoryViewModel
{
Filters = filter,
FCategories = fcat
};
return View(modelim);
}
[HttpPost]
public ActionResult AddToCategory(string seo, string name,????????? filters)
{//......}
如何在控制器上显示和获取optgroup值?