我无法从MVC中的html获取发布的值。我在html中有3个控件。其中一个是DropDownList,其中两个是DateTime。我可以获取DateTimes的值但无法获取DropDownList。这是我的代码来自html
@Html.DropDownListFor(M => M.AntsoftCrmUser, new SelectList(Model.AntsoftCrmUser, "Id", "Username"))
@Html.TextBoxFor(model => model.StartDate, new { htmlAttributes = new { @class = "form-control" }, type = "datetime-local" })
@Html.TextBoxFor(model => model.EndDate, new { htmlAttributes = new { @class = "form-control" }, type = "datetime-local" })
这是我的控制器代码,在html发布后调用...
[HttpPost]
public ActionResult UserTotalTimeSpentReport(int? Id,DateTime? StartDate,DateTime? EndDate)
{
return View();
}
如何从DropDownList获取值?我应该使用" int吗? ID"或"字符串用户名" ?