我在 Webgrid 上方创建了一个下拉框,如果用户从下拉框中选择任何值,我的 webgrid 会更改每页的行,所以......但它不能正常工作并且我的 webgrid 没有更新,所以请给我提示以实现它..这是我的代码..这里查看....代码
<div id="contentwrapper" class="contentwrapper">
<form id="opation" action="">
<div class="tableoptions">
<button class="submit radius2" id="Act" onclick="submitForm(this.id);">Active</button> <button class="submit radius2" id="Dec" onclick="submitForm(this.id);">DeActive</button> <button class="submit radius2" id="Del" onclick="submitForm(this.id);">Delete</button> @using (Ajax.BeginForm(new AjaxOptions{ InsertionMode = InsertionMode.Replace, UpdateTargetId = "myGrid" })) { <label>Search User: </label><input type="text" name="UserName" id="UserName" value=""/> <button class="submit radius2" id="Search" value="Search">Search</button>}
</div>
</form>
Record Per Page: <form id="test" action=""><select name="DD" class="tbl_top_link" name="Pagelimit" id="Pagelimit" onchange="Count(this.value);"><option value="">- Select -</option><option id="1" value="1">1</option><option id="5" value="5">5</option><option id="10" value="10">10</option><option id="20" value="20">20</option><option id="30" value="30">30</option></select></form>
@{
var temp = converttoInt16(ViewData["Pagesize"]);
var grid = new WebGrid(source: Model,
defaultSort: "Name", rowsPerPage: temp,
selectionFieldName: "SelectedRow", canPage: true);
//grid.Pager(mode: WebGridPagerModes.All,
// firstText: "First", lastText: "Last",
// previousText: "Previous",
// nextText: "Next",
// numericLinksCount: 15);
<div id="mygrid">
@grid.GetHtml(tableStyle: "gridTable",
headerStyle: "gridHead",
footerStyle: "gridFooter",
rowStyle: "gridRow",
alternatingRowStyle: "gridAltRow",
columns: grid.Columns(
grid.Column(header: "", format: @<text><input type="checkbox" name="chkactive[]" id="chkactive[]" value="@item.User_id"/></text>),
grid.Column("User_Id"),
grid.Column("Name"),
grid.Column("Username"),
grid.Column("Fb_Id"),
grid.Column("User_image", format: @<text><img src="@Url.Content(@item.Image_path)" height="30px" width="50px" alt="noimage"/></text>),
grid.Column("Email"),
grid.Column("Gender"),
grid.Column(header: "Status", format: @<text>@if (@item.Is_active == true)
{ <a href="@Url.Action("UserStatus", "Admin", new { id = @item.User_id })"><img src="../../images/Active.png"/></a> }
else
{ <a href="@Url.Action("UserStatus", "Admin", new { id = @item.User_id })"><img src="../../images/Deactive.png"/></a> }</text>),
grid.Column(header: "Edit",
format: @<text><a href="@Url.Action("EditeUser", "Admin", new { id = @item.User_id })"><img src="../../images/icons/editor.png" /></a></text>),
grid.Column(header: "Delete",
format: @<text><a href="@Url.Action("DeleteUser", "Admin", new { id = @item.User_id })"><img src="../../images/icons/trash.png"/></a></text>)))
</div>
}
</tbody>
</table>
</form>
</div>
在这个视图中,我有一个 DRop 下拉框和 Onchange 事件调用我的 java sript 来确定选择了哪个值,然后发布到我的操作结果方法以执行我的逻辑并返回到视图,但我的视图没有更改或 webgrid没有更新..所以请帮助我..或者告诉我如何使用 webgrid 上的下拉菜单来执行此功能
这是我的 JAVASCRIPT
<script type="text/javascript" language="javascript">
function Count(value)
{
alert(value);
$.post('@Url.Action("Pagesize","Admin")',
{
rowsPerPage: value
});
}
这是我的操作结果方法:----
[HttpPost]
public ActionResult Pagesize(int rowsPerPage)
{
//if (rowsPerPage == 0)
//{
// ViewBag.Pagesize = 3;
//}
//else
//{
// ViewBag.Pagesize = Convert.ToInt32(rowsPerPage);
//}
ViewData["pagesize"] = rowsPerPage;
//return View(db.User_Masters.ToList());
// return RedirectToAction("Userlist");
var u_master = db.User_Masters.ToList();
return PartialView("OneRow",u_master);
}