title: ASP.NET MVC With Kendo UI Grid Cannot Create Update and Destroy
body: <p>I am trying to build ASP.NET App using Kendo UI and I face a problem when I want to Create, Update, and Destroy. There is no Error When I built it. It Display Well and when I try to add something, It goes as it should. It still Display what I just Create. but After I refresh the page that data isn't there.
  And Nothing Change on Database, no data added.</p>
  
  <p>Here's my Controller:</p>
  
  <pre><code>public ActionResult _Index([DataSourceRequest]DataSourceRequest request)
      {
          var u = db.Unit.Select(n =&gt; new { n.UnitID,n.KodeUnit, n.NamaUnit, n.JumlahPegawai });
          DataSourceResult result = u.ToDataSourceResult(request);
          return Json(result, JsonRequestBehavior.AllowGet);
      }
  
      [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult _Create([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable&lt;Unit&gt; unit)
      {
          var results = new List&lt;Unit&gt;();
  
          if (unit != null &amp;&amp; ModelState.IsValid)
          {
              foreach (var u in unit)
              {
                  db.Unit.Add(u);
                  db.SaveChanges();
              }
          }
  
          return Json(results.ToDataSourceResult(request, ModelState));
      }
  
      [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult _Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable&lt;Unit&gt; unit)
      {
          if (unit != null &amp;&amp; ModelState.IsValid)
          {
              foreach (var u in unit)
              {
                  db.Entry(u).State = EntityState.Modified;
                  db.SaveChanges();
              }
          }
  
          return Json(new[] { unit }.ToDataSourceResult(request, ModelState));
      }
  
      [AcceptVerbs(HttpVerbs.Post)]
      public ActionResult _Destroy([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable&lt;Unit&gt; unit)
      {
          if (unit.Any())
          {
              foreach (var u in unit)
              {
                  db.Unit.Remove(u);
                  db.SaveChanges();
              }
          }
  
          return Json(unit.ToDataSourceResult(request, ModelState));
      }
  </code></pre>
  
  <p>And Here's my Model:</p>
  
  <pre><code>namespace Aplikasi_PKPT.Models
  {
  
  public class Unit
      {
      [Key]
      public int UnitID { get; set; }
  
      [Display(Name="Kode Unit")]
      [Required(ErrorMessage="Kode Unit Tidak Boleh Kosong")]
      public string KodeUnit { get; set; }
  
      [Display(Name = "Nama Unit")]
      [Required(ErrorMessage = "Nama Unit Tidak Boleh Kosong")]
      [StringLength(60, ErrorMessage = "Nama Unit Tidak Boleh Melebihi 60 Karakter")]
      public string NamaUnit { get; set; }
  
      [Display(Name = "Jumlah Pegawai")]
      [Required(ErrorMessage = "Jumlah Pegawai Tidak Boleh Kosong")]
      public int JumlahPegawai { get; set; }
  
      public virtual ICollection&lt;Pkpt&gt; Pkpt { get; set; }
      public virtual ICollection&lt;User&gt; User { get; set; }
      public virtual ICollection&lt;Korkel&gt; Korkel { get; set; }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And Here's my Index View:</p>
  
  <pre><code>&lt;div class="container" style="margin-top:100px; padding-bottom:100px;"&gt;
  @(Html.Kendo().Grid&lt;Aplikasi_PKPT.Models.Unit&gt;()
      .Name("Grid")
      .DataSource(datasource =&gt; datasource
          .Ajax()
          .Model(model =&gt; model.Id(id =&gt; id.UnitID))
          .Read(read =&gt; read.Action("_Index", "Unit"))
          .Create(update =&gt; update.Action("_Create","Unit"))
          .Update(update =&gt; update.Action("_Update", "Unit"))
          .Destroy(update =&gt; update.Action("_Destroy", "Unit"))
      )
      .Columns(columns =&gt;
          {
          columns.Bound(u =&gt; u.KodeUnit);
          columns.Bound(u =&gt; u.NamaUnit);
          columns.Bound(u =&gt; u.JumlahPegawai);
          columns.Command(command =&gt; { command.Edit(); command.Destroy(); });
          }
      )
      .ToolBar(toolbar =&gt; {
          toolbar.Create();
      })
      .Editable(editable =&gt; editable.Mode(GridEditMode.PopUp))
      .Sortable()
      .Filterable()
      .Events(e =&gt; e.Edit("hideIdField"))
  
  )
      &lt;script&gt;
          function hideIdField(e) {
              $("#UnitID").hide();
              $("label[for='UnitID']").hide();
          }
      &lt;/script&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Any Help Would be apreciated..</p>