2012-07-18 73 views
0

我使用的是telerik mvc 3.參數在刪除方法中總是NULL,不知道爲什麼

我有一個綁定到ViewModel的網格。

@(Html.Telerik().Grid<SampleProject.ViewModels.Location.RoomViewModel>() 
      .Name("Grid") 
      .ToolBar(cmd => cmd.Insert()) 
      .DataKeys(keys => keys.Add(c => c.RoomId)) 
      .DataBinding(dataBinding => dataBinding 
        .Ajax() 
        .Select("Selecting", "Location") 
         .Insert("Inserting", "Location") 
          .Update("Updating", "Location") 
          .Delete("Deleting", "Location") 
         ) 
      .Columns(c => 
       { 
        c.Bound(o => o.RoomName); 
        c.Bound(o => o.MaxSeats); 
        c.Bound(o => o.HasScanner); 
        c.Bound(o => o.HasPrinter); 
        c.Bound(o => o.HasFlipchart); 
        c.Bound(o => o.HasBeamer); 
        c.Command(cmd => 
         { 
          cmd.Edit(); 
          cmd.Delete(); 
         }); 
       }) 
     ) 

「插入」 - 方法工作正常(我把RoomViewModel作爲參數)。 「選擇」 - 方法也起作用,但「刪除」 - 方法不起作用。

#region GridActions 
    [GridAction] 
    public ActionResult Selecting() 
    { 
     return View(new GridModel(this._currentLocation.Rooms)); 
    } 

    [AcceptVerbs(HttpVerbs.Post)] 
    [GridAction] 
    public ActionResult Inserting(RoomViewModel rvm) 
    { 
     this._currentLocation.Rooms.Add(rvm); 
     return View(new GridModel(this._currentLocation.Rooms)); 
    } 

    [AcceptVerbs(HttpVerbs.Post)] 
    [GridAction] 
    public ActionResult Deleting(RoomViewModel rvm) 
    { 
     this._currentLocation.Rooms.Remove(rvm); 
     return View(new GridModel(this._currentLocation.Rooms)); 
    } 

我也嘗試:

 public ActionResult Deleting(int rvm) --> internal error 500 - doesnt hit the breakpoint 

     public ActionResult Deleting(string rvm) 

     public ActionResult Deleting(object rvm) 

總是 「NULL」,任何想法???

回答

0

實際刪除操作方法期望實體身份作爲參數:

public ActionResult _DeleteAjaxEditing(int id) 
相關問題