我在部分页面中有一个WebGrid,并且从另一个页面内的Controller调用部分页面,一切正常,除了分页。当我尝试转到下一页记录时,它会恢复到主页面,而不是Webgrid。
我的控制器代码:
[HttpPost]
public ActionResult StatisticsHistory(FormCollection fc)
{
List<StatisticsHistoryData> hisData = new List<StatisticsHistoryData>();
........
if (hisData != null)
{
hisData = StatisticsHistoryMethods.HistoryDetailsBetweenDates(fromDate, toDate, environmentId);
return PartialView("_StatusHistoryGrid", hisData);
}
else
{
}
return StatisticsHistory();
}
我在部分页面中的Webgrid:
@model IEnumerable<AppFabricAdmin.Models.StatisticsHistoryData>
@{var Grid = new WebGrid(source: Model, canPage:true, rowsPerPage:2, canSort: true);
}
@{
if (Model.Count() > 0)
{
@Grid.GetHtml(tableStyle: "webGrid", headerStyle: "header", alternatingRowStyle: "alt", mode: WebGridPagerModes.All,
columns: Grid.Columns(Grid.Column("Environment", format: @<b>@item.Environment</b>, style: "AIDColumn"),
Grid.Column("Initial Status", format: @<b>@item.InitialStatus</b>, style: "FirstNameColumn"),
Grid.Column("Final Status", format: @<b>@item.FinalStatus</b>, style: "LastNameColumn"),
Grid.Column("Action Taken", format: @<b>@item.ActionTaken</b>, style: "EmailIDColumn"),
Grid.Column("Comments", format: @<b>@item.Comments</b>, style: "EmailIDColumn"),
Grid.Column("Time Stamp", format: @<b>@item.TimeStamp</b>, style: "EmailIDColumn")
))
}
else
{
<p>
No records found.</p>
}
我也尝试在主页面中使用@using(Ajax.BeginForm()),并且hv也尝试在网格中使用ajaxUpdateContainerId:“grid”,但没有任何效果。请帮助。