2011-06-09 78 views
0

我有类如何创建类对象在Asp.net MVC

public class TabMasterViewModel : ITabMasterModel 
    { 
     [ReadOnly(true)] 
     public int colID { get; set; } 
     [DisplayName("FirstName")] 
     public string FirstName { get; set; } 
     [DisplayName("LastName")] 
     public string LastName { get; set; } 
    } 

现在我想删除以下从数据库

[HttpPost] 
     public ActionResult RemoveSelected(IList<TabMasterViewModel> TabMasters) 
     { 
      IList<TabMasterViewModel> TabMasters = new IList<TabMasterViewModel>; //this line is giving me an ERROR.. 
      List<string> dinosaurs = new List<string>(); 

      int[] colIDs = { 1034, 1035, 1036 }; 
      foreach (int colid in colIDs) 
      { 
       //TabMasters.Add(new TabMasterViewModel { colID = colid }); 
       TabMasterViewModel tvm = new TabMasterViewModel { colID = colid }; 
       TabMasters.Add(tvm); 
       //_tabmasterService.Delete(tvm); 
      } 
      _tabmasterService.DeleteList(TabMasters); 
      //return View(_tabmasterService.GetAll(x => (x.colID == 1034 || x.colID == 1035 || x.colID == 1036))); 
      return RedirectToAction("Index"); 
     } 

三张唱片,但我没有ABEL写正确的

IList<TabMasterViewModel> TabMasters = new IList<TabMasterViewModel> 

回答

3
IList<TabMasterViewModel> TabMasters = new List<TabMasterViewModel>(); 

的IList <>是一个接口,不能实例化。

+0

优秀和快速的答案。谢谢哥们! – imdadhusen 2011-06-09 11:48:24