以下是我的MVC WebGrid代码
@ var grid = new WebGrid(来源: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? }),
答案 0 :(得分:0)
您可以添加其他参数以及ID
尝试以下代码
var link = Html.ActionLink("Add New", "AddNew", "Admin", new { id = item.id, user_email = "UserEmail" }, htmlAttributes: new { @class = "btn btn-xs btn-vs" });
由于