public class UserDetailsModel
{
public int ID { get; set; }
public string LoginID { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string IsDeleted { get; set; }
public DateTime CreatedOn { get; set; }
}
控制器:
public ActionResult Index()
{
object model = obj.getUserList();
return View(model);
}
public ActionResult Delete(int id)
{
BAL_obj.deleteUser(id);
object model = obj.getUserList();
return View("Index",model);
}
索引.cshtml:
@model IEnumerable<WebGrid1App.Models.UserDetailsModel>
@{
WebGrid grid = new WebGrid(Model);
}
<h2>People</h2>
@grid.GetHtml(
headerStyle: "headerStyle",
tableStyle: "tableStyle",
alternatingRowStyle: "alternateStyle",
fillEmptyRows: true,
mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
nextText: "Next >",
lastText: "Last >>",
columns: new [] {
grid.Column("ID",header: "ID"),
grid.Column("LoginId",header:"LoginID"),
grid.Column("FirstName", canSort: false),
grid.Column("LastName"),
grid.Column("CreatedOn",
header: "CreatedOn",
format: p=>p.CreatedOn.ToShortDateString()
),
grid.Column("",
header: "Actions",
format: @<text>
@Html.ActionLink("Edit", "Edit", new { id=item.ID} )
|
@Html.ActionLink("Delete", "Delete", new { id=item.ID} )
</text>
)
})
我已经完成了删除操作。如何在同一页面上编辑一行并将更改保存到数据库中?
会有编辑按钮。当您单击它时,行将是可编辑的。同时编辑链接文本更改为保存链接。现在,当您单击保存时,需要更新行。
我想做内联编辑。你能帮我解决这个问题吗?