当用户使用 ajax 更改下拉值时,我想更改网格日期。这是我的 C# 代码:
public ActionResult Index(string name)
{
ViewBag.Drop = db.Students.Select(r => r.Fname);
var model = from r in db.Students
where r.Fname == name
select r;
return View(model);
}
这是cshtml
文件:
@using (Ajax.BeginForm("Index", new AjaxOptions
{
UpdateTargetId = "grid",
HttpMethod = "GET"
}
))
{
@Html.DropDownList("name", new SelectList(ViewBag.Drop));
<input type = "submit" value = "submit" />
}
<div id= "grid">
</div>
我的问题是,当我更改下拉值时,所有视图都会再次显示。我不想看到新视图,只想更改网格数据。我怎样才能做到这一点?