title: Model Binding fails with Kendo Grid
body: <p>I can't use edit and create command of a Kendo Grid, because binding always fails and controller always receives a <code>null</code> object, even though <code>DataSourceRequest</code> is fine.</p>
  
  <p>I used a <code>@html.EditorForModel()</code> and it worked fine and controller received the data. So MVC Model binding and my class aren't the problem.</p>
  
  <p>Also, using F12, I can see the data being posted and it's fine too. </p>
  
  <p>Any Idea about possible problem and debugging? There is an issue with all of my Kendo Grids, sometimes they post a model twice and I receive double <code>Create</code> on the server, which one of them always fails because of repetitive Keys. Or sometimes create will be triggered by edit command too.</p>
  
  <p>I have no idea where I'm going wrong, in most scenarios the user will choose the primary key as well, so my returned model doesn't need an update.</p>
  
  <p>With this particular class, server always receives two create and none of them binds correctly. The first create, posts all of the fields, and the second posts all of the navigation properties' fields too!</p>
  
  <p>This is the action method:</p>
  
  <pre><code>[HttpPost]
  public ActionResult Create([DataSourceRequest] DataSourceRequest request, Stock stock){
          if (stock != null &amp;&amp; ModelState.IsValid)
          {
              repo.Insert(stock);
              return Json(new[] { stock }.ToDataSourceResult(request, ModelState));
          }
          else
              return Json(null);
  }
  </code></pre>
  
  <p>And the Grid:</p>
  
  <pre><code>@(Html.Kendo().Grid&lt;Stock&gt;()
      .Name("stock")
          .Columns(columns =&gt;
          {
              columns.ForeignKey(x =&gt; x.CGoodCode, (IEnumerable)ViewData["Goods"], "Id", "Text");
              ///
              columns.Command(command =&gt; { command.Edit(); command.Destroy(); });
          })
          .ToolBar(toolbar =&gt; {
              toolbar.Create();
              toolbar.Excel();
              toolbar.Pdf();
          })
          .Editable(edit =&gt; edit.Mode(GridEditMode.PopUp))
          .Sortable()
          .Pageable(p =&gt; p.PageSizes(true))
          .DataSource(ds =&gt; 
              ds.Ajax()
              .Model(model =&gt; {
                  model.Id(x =&gt; x.CGoodCode);
                  model.Id(x =&gt; x.SWhCode);
                  model.Id(x =&gt; x.LiIdPeriod);
                  model.Field(x =&gt; x.CGoodCode).DefaultValue(ViewData["GoodsDefault"]);
                  ////
  
              })
              .Read("Read", "Stock")
              .Update("Edit", "Stock")
              .Create("Create", "Stock")
              .Destroy("Delete", "Stock")
          )
  )
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>It seems Kendo Grid doesn't support <a href="http://www.telerik.com/forums/composite-datakey-in-kendo-ui-mvc" rel="nofollow">composite primary keys</a> yet!</p>