开发者

How to create Object for Class in Asp.net MVC

开发者 https://www.devze.com 2023-03-12 04:19 出处:网络
I have class public class TabMasterViewModel : ITabMasterModel { [ReadOnly(true)] public int colID { get; set; }

I have class

 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; }
    }

Now i want to delete following three records from database

 [HttpPost]
        public ActionResult RemoveSelected(IList<TabMasterViewModel> TabMasters)
        {
            IList<TabMasterViewModel> Ta开发者_如何学PythonbMasters = 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");
        }

but i am not abel to write proper for

IList<TabMasterViewModel> TabMasters = new  IList<TabMasterViewModel>


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

IList<> is an interface and cannot be instantiated.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号