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; }
}
Controller:
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);
}
Index.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>
)
})
I have done with the delete operation. How can I edit a row on same page and save the changes into database?
There will edit button. When you click on it, row will be editable. Meanwhile edit link text is changed as Save link. Now when you click on Save, row needs to be updated.
I want to do Inline editing. Can you please help me out with this?