如果表单状态回发,我想不绑定我的下拉列表。正如您在我的代码中看到的,我有两个表单和两个提交按钮。单击第二个提交按钮后,我想保留下拉列表的选定值。
<form method="POST" action="@Url.Action("UserRoles", "PageUserRole")">
<label>Kullanıcı Grubu</label>
@Html.DropDownList("Id", Utility.GetUserGroups(), "Kullanıcı Grubu Seçiniz.")
<input type="submit" value="Listele" />
</form>
...
<form method="POST" action="@Url.Action("EditUserRoles", "PageUserRole")">
<table>
<tbody>
<tr>
<td>
İşlem
</td>
<td>
Yetki
</td>
</tr>
@for (int i = 0; i < Model.PageMenUsuserRoles.Count; i++)
{
<tr>
<td>
@Model.PageMenUsuserRoles[i].pagemenu.Name
</td>
<td>
@Html.Hidden("PageMenUsuserRoles[" + i + "].Id", Model.PageMenUsuserRoles[i].Id)
@Html.CheckBox("PageMenUsuserRoles[" + i + "].CanView", Model.PageMenUsuserRoles[i].CanView)
</td>
</tr>
}
<tr>
<td colspan="2">
<input type="submit" value="Kaydet" />
</td>
</tr>
</tbody>
</table>
</form>