【发布时间】:2017-12-25 23:24:52
【问题描述】:
下面是我的 MVC WebGrid 代码
@ var grid = new WebGrid(source: Model, canPage: true, rowsPerPage: 5、canSort: true);
@grid.GetHtml(columns: grid.Columns(
grid.Column(header: "#",
format: item => item.WebGrid.Rows.IndexOf(item) + 1 + Math.Round(Convert.ToDouble(grid.TotalRowCount / grid.PageCount) / grid.RowsPerPage) * grid.RowsPerPage * grid.PageIndex),
//format: item => item.WebGrid.Rows.IndexOf(item) + 1),
grid.Column(header: "Full Name", columnName: "full_name",canSort:false),
grid.Column(header: "User Name", columnName: "user_name", canSort: false),
grid.Column(header: "Password", columnName: "password", canSort: false),
grid.Column(header: "User Email", columnName: "user_email", canSort: false),
grid.Column(header: "Role", columnName: "role"),
grid.Column(header: "",format:(item) =>
{
var link = Html.ActionLink("Add New", "AddNew", "Admin", new { id = item.id }, htmlAttributes: new { @class = "btn btn-xs btn-vs" });
return link;
}),
grid.Column(header: "", format: (item) =>
{
//var link = Html.ActionLink("Edit", "", "", new { id = item.id }, htmlAttributes: new { @class = "btn btn-xs btn-primary", onclick = "Modalshow()" });
var link = Html.ActionLink("Edit", "Edit", "Admin", new { id = item.id }, htmlAttributes: new { @class = "btn btn-xs btn-primary" });
return link;
}),
grid.Column(header: "", format: (item) =>
{
var link = Html.ActionLink("Delete", "Delete", "Admin", new { id = item.id }, htmlAttributes: new { @class = "btn btn-xs btn-danger", onclick = "return confirm('Are you sure you want to delete this item?');" });
return link;
}),
grid.Column(header: "", format: (item) =>
{
var link = Html.ActionLink("Details", "Select", "Admin", new { id = item.id }, htmlAttributes: new { @class = "btn btn-xs btn-success " });
return link;
})
)
, htmlAttributes: new { @class = "table table-hover text-center" },
nextText: "Go Next",
previousText: "Go Back",
footerStyle: ""
)
在下面的部分中
grid.Column(header: "",format:(item) =>
{
var link = Html.ActionLink("Add New", "AddNew", "Admin", new { id = item.id }, htmlAttributes: new { @class = "btn btn-xs btn-vs" });
return link;
如何将 user_email 作为参数传递来代替 item.id ? }),
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-5