【发布时间】:2015-04-29 14:44:42
【问题描述】:
我有一个小问题,我必须将参数从视图传递给控制器,我用输入字段成功了,但是用@html.dropdownList我不知道该怎么做,你能请帮帮我,这是我的代码:
查看:
@using (Ajax.BeginForm("GetFilterList", "Inconsistencies",
new AjaxOptions
{
HttpMethod = "POST",
UpdateTargetId = "refreshList",
}, new { @id = "FileList" }
))
{
<span class="input-group-addon">Date de début</span>
<input type="text" class="form-control date-picker" placeholder="jj/mm/aaaa" id="StartDate" name="StartDate" />
<span class="input-group-addon">Date de fin</span>
<input type="text" class="form-control date-picker" placeholder="jj/mm/aaaa" id="EnDate" name="EnDate" />
<span class="input-group-addon">Etat inco</span>
@Html.DropDownListFor(m => m.Inconsistences.InconsistencyStateId, Model.StateList, new { id = "state", }) //how to pass the selected value to controller ?
<span class="input-group-addon">Type inco</span>
<input type="text" class="form-control" id="type" name="type" />
<button type="submit" class="btn btn-sm fsc-btn-1" id="search">
<i class="fa fa-search"></i>
<span>Recherche</span>
</button>
}
控制器:
[HttpPost]
public ActionResult GetFilterList(DateTime? StartDate, DateTime? EnDate, decimal? State, decimal? type)
{
InconsistenciesModel model = new InconsistenciesModel();
model.FillDDL();
model.GetListFilter(StartDate, EnDate,State, type);
return PartialView("_InconsistenciesList", model);
}
【问题讨论】:
标签: asp.net-mvc