我将数据从数据库绑定到 webgrid,我想在 webgrid 的每一行中保留一个 actionlink 编辑,尝试了下面的一个但Object reference not set to an instance of an object
在下面的行附近出现错误,我的模型名称是 User
foreach(var item in Model)
我还发布了整个代码
var grid = new WebGrid(source: MvcPopupGrid.Models.User.Users, rowsPerPage: 5);
@grid.GetHtml(
tableStyle: "grid", headerStyle: "gridhead", footerStyle: "paging", rowStyle: "td-dark", alternatingRowStyle: "td-light",
columns:
grid.Columns(
grid.Column(header: "Id", format: @<text><label id="lblId" title="@item.Id">@item.Id</label></text>),
grid.Column(header: "Name", format: @<text><label id="lblName" title="@item.Name">@item.Name</label></text>),
grid.Column(header: "College", format: @<text><label id="lblCollege" title="@item.College">@item.College</label></text>),
grid.Column(header: "PassedOut", format: @<text><label id="lblPassedOut" title="@item.PassedOut">@item.PassedOut</label></text>),
grid.Column(header: "Mobile", format: @<text><label id="lblMobile" title="@item.Mobile">@item.Mobile</label></text>)))
foreach(var item in Model)
{
@item.Id
@item.Name
@item.College
@item.PassedOut
@item.Mobile
@Html.ActionLink("Edit", "UserEdit", new { Id = "@item.Id" }, new { @class = "abookModal", title = "Edit User" })
}