2014-01-24 25 views
1

我想在MVC4中的WebGrid上實現插入,更新,刪除操作。我該怎麼做?我們如何在mvc4中的wegrid上插入更新刪除操作?

這是我的Web網標準

@model IEnumerable<MVC24Jan.UserTable> 

@{ 
    ViewBag.Title = "ShowRecord"; 
    WebGrid grid = new WebGrid(Model); 
} 

<h2>ShowRecord</h2> 

<div> 
@grid.GetHtml(
    tableStyle: "webgrid", 
    headerStyle: "head", 
    alternatingRowStyle: "alt", 
    columns:grid.Columns(
      grid.Column("UserId"), 
      grid.Column("UserName"), 
      grid.Column("Address") 
      ) 

     ) 
</div> 

這我控制器代碼

public ActionResult ShowRecord() 
    { 
     DBLayer db = new DBLayer(); 
     var usertablList= db.GetAllRecord(); 
     return View(usertablList); 
    } 

public List<UserTable> GetAllRecord() 
    { 
     List<UserTable> userTable = new List<UserTable>(); 
     userTable = entity.UserTables.ToList(); 
     return userTable; 
    } 

我如何能實現插入,更新和該網格刪除操作?

+0

我得到了一些參考形式http://www.codeproject.com/Articles/695850/Complete-CRUD -operations式-MVC – user3230757

回答

相關問題