我有以下 .cshtml
<fieldset>
<legend></legend>
<p>
@using (Html.BeginForm("PlayerList", "Players", new{id = "Id"}, FormMethod.Post))
{
@Html.DropDownListFor(Model => Model.Teams, new SelectList(Enumerable.Empty<SelectListItem>(), "Id", "Name"),
"Select a Team", new { id = "ddlTeams" }) <input type="submit" value="Get Player List" />
}
</p>
</fieldset>
DropDownList 由一些 javascript 填充:
$("#ddlComps").change(function () {
var compid = $(this).val();
$.getJSON("../Players/LoadTeamsByCompId", { compid: compid },
function (teamsData) {
var select = $("#ddlTeams");
select.empty();
select.append($('<option/>', {
value: 0,
text: "Select a Team"
}));
$.each(teamsData, function (index, itemData) {
select.append($('<option/>', {
value: itemData.Value,
text: itemData.Text
}));
});
});
});
为什么单击提交按钮时,没有将 Id 参数传递给 ActionResult PlayerList
?