title: Unable to cast object of type 'System.Data.Entity.DynamicProxies.QuanTri_8853081F254D1D30AC78D5C548A68F29C932951DF7E094DA751FE0A3AA80E911'
body: <pre><code>        public ActionResult AddChucNangQuanTri()
          {
              ViewBag.MaQuanTri = new SelectList(db.QuanTris, "ID", "Ten");
              var data = db.ChucNangs.ToList();
              Chuc_Nang_Quan_Tri cnqt = new Chuc_Nang_Quan_Tri();
              cnqt.ChucNang = data;
              return View(cnqt);
          }
  
          [HttpPost]
          [ValidateAntiForgeryToken]
          public ActionResult AddChucNangQuanTri(FormCollection fc)
          {
              if (ModelState.IsValid)
              {
                  var a = fc.GetValues("MaChucNang");
                  int quantri = Convert.ToInt32(fc["MaQuanTri"].ToString());
                  List&lt;Chuc_Nang_Quan_Tri&gt; del = db.Chuc_Nang_Quan_Tri.Where(x=&gt;x.MaQuanTri == quantri).ToList();
                  foreach (var item in del)
                  {
                      db.Chuc_Nang_Quan_Tri.Remove(item);
                  }
                  db.SaveChanges();
                  Chuc_Nang_Quan_Tri cnqt = new Chuc_Nang_Quan_Tri();
                  for (int i = 0; i &lt; a.Count(); i++)
                  {
                      cnqt.MaQuanTri = quantri;
                      cnqt.MaChucNang = int.Parse(a[i]);
                      db.Chuc_Nang_Quan_Tri.Add(cnqt);
                      db.SaveChanges();
                  }
                  ViewBag.MaQuanTri = new SelectList(db.QuanTris, "ID", "Ten", quantri);
                  return View();
              }
  
              return View();
          }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/i8PqT.jpg" rel="nofollow noreferrer">enter image description here</a>
   ####view</p>
  
  <p>I need to pass through view 2 lists. One is SelectList, the other is a checkbox list, I saved it but encountered this problem
  I think I have a problem with the viewbag.MaQuanTri. wish everyone helped me</p>