【发布时间】:2014-04-17 04:16:43
【问题描述】:
在我的 ASP.NET MVC 5 网站中,我遇到了这种情况:
我有一个 GridView,我可以只获取默认行或所有行(包括已删除的行)。我正在尝试使用名为“cbxGetAll”的视图功能区中的复选框来控制它。
所以,这是我的脚本:
<script>
function OnCommandExecuted(s, e) {
if (e.item.name == "cbxGetAll") {
if (e.parameter) {
window.location.href = '@Url.Action("Index",new {getAll = true})';
return;
} else {
window.location.href = '@Url.Action("Index",new {getAll = false})';
return;
}
}
</script>
还有我的行动:
public ActionResult Index(bool? getAll)
{
if (getAll != null && (bool) getAll)
{
//Return Without Filter
}
else
{
//Return With Filter
}
}
我更改了 URL 中的 getAll 参数,它运行良好。 但问题是,当 ActionResult 完成时,它会重新加载页面(当然),然后我失去了复选框状态。 我该如何处理?
【问题讨论】:
标签: c# asp.net asp.net-mvc checkbox