我有一个带有搜索选项的视图来过滤结果:
@model GWeb.Models.FilterModel
@using (Html.BeginForm())
{
@Html.ValidationSummary(true)
<fieldset>
<legend>Search criteria</legend>
@(Html.Telerik().ComboBox()
.Name("UserName")
.BindTo(new SelectList(ViewBag.workerList as System.Collections.IEnumerable, "Id", "Desciption"))
.Value(Model.UserName))
@(Html.Telerik().DatePicker()
.Name("StartWork")
.Value(Model.StartWork))
@(Html.Telerik().DatePicker()
.Name("EndWork")
.Value(Model.EndWork))
<input type="submit" value="Filter" />
</fieldset>
}
@{Html.RenderPartial("EmployeeList", (IEnumerable<GWeb.Entities.Work>)ViewBag.employeeList);}
RenderPartial 是可以编辑的项目列表:
<td>
<a href="@Url.Action("Edit", "Admin", new { id = item.Id })">
<img src="/Content/edit.png" alt="Edit" title="Edit" width="22" height="22" />
</a>
编辑视图是标准的脚手架生成视图。FilterModel 包含:
public class FilterModel
{
public string UserName { get; set; }
public DateTime? StartWork { get; set; }
public DateTime? EndWork { get; set; }
//...
}
问题:当我编辑其中一项并返回主视图时,搜索条件消失了。我怎样才能记住设置为的值FilterModel
?这样在编辑或查看列表中的项目后,我可以返回到之前设置的相同过滤器选项?
非常感谢任何帮助!