title: unable to insert Telerik RadGrid In-Place insert using OnInsertCommand e.item
body: <p>I am trying to perform an insert using teleriks rad grid. I am doing an in-place insert and using the onInsertCommand method to set the values that are to be insertted. i found this statement in telerik's documnetation:</p>
  
  <p>GridEditableItem editedItem = e.Item as GridEditableItem; when i use it editedItem is getting null value and i dont know how to make it work:</p>
  
  <p>Here is my code behind for InsertCommand</p>
  
  <p>protected void RadGrid1_InsertCommand(Object Sender, Telerik.Web.UI.GridCommandEventArgs e)
      {     </p>
  
  <pre><code>        GridEditableItem editedItem = e.Item as GridEditableItem;
  
          Hashtable newValues = new Hashtable();
  
          e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
          editedItem.Edit = false;
  
          Yieldco.RS.Libraries.BusinessObjects.UnitType u1 = new Yieldco.RS.Libraries.BusinessObjects.UnitType();
  
          u1.Description = newValues["Description"].ToString();
  
          u1.UnitTypeID = Convert.ToInt32(e.Item.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["UnitTypeID"]);
          u1.CommunityID = 1;
          u1.CompanyID = 1;
          u1.Bathrooms = (float)Convert.ToDouble(newValues["Bathrooms"]);
          u1.Bedrooms = Convert.ToInt32(newValues["Bedrooms"]);
          u1.SqFtHigh = (float)Convert.ToDouble(newValues["SqFtHigh"]);
          u1.SqFtLow = (float)Convert.ToDouble(newValues["SqFtLow"]);
          u1.NumOfUnits = Convert.ToInt32(newValues["NumOfUnits"]);
          u1.ProCon = Convert.ToInt32(newValues["ProCon"]);
          u1.OthCon = Convert.ToInt32(newValues["OthCon"]);
          u1.RentHigh = (float)Convert.ToDouble(newValues["RentHigh"]);
          u1.RentLow = (float)Convert.ToDouble(newValues["RentLow"]);
          u1.Status = 1;
  
          int id = MSController.SaveUnitTypes(u1);
  }
  </code></pre>
  
  <p>and my aspx radgrid</p>
  
  <p><br>
             
             AutoGenerateColumns="false" AllowAutomaticUpdates="false" AllowAutomaticInserts="false"  DataKeyNames="UnitTypeID" GridLines="Both"<br>
             EditItemStyle-Width="24px">
                  
                      
                      
                      
                      
                      
                      
                      
                      
                      
                      
                      
                      
                      &lt;%--<br>
                      --%>
                      
                          
                              
                          
                      
                  <br>
                  
                      ' runat="server" ID="Addnew" Text="Add New" CommandName="InitInsert" />
                      ' runat="server" ID="CancelAdd" Text="Cancel" CommandName="CancelAll" />&nbsp;&nbsp;
                      ' runat="server" ID="InsertNew" Text="Perform Insert" CommandName="PerformInsert" />&nbsp;&nbsp;<br>
                      ' runat="server" ID="EditAll" Text="Edit All" CommandName="EditAll" />
                       0 %>' runat="server" ID="CancelEdit" Text="Cancel" CommandName="CancelAll" />&nbsp;&nbsp; 
                       0 %>' runat="server" ID="UpdateAll" Text="Update All" CommandName="UpdateAll" OnClientClick='javascript:return confirm("Are you sure you want to Update All Records?")' /><br>
                  
             
          </p>
  
  <pre><code>     &lt;asp:ObjectDataSource ID="odsGetUnitTypes" runat="server"
      TypeName="Yieldco.RS.Libraries.Controllers.MSController" 
      DataObjectTypeName="Yieldco.RS.Libraries.BusinessObjects.UnitType" 
      SelectMethod="GetUnitTypesByCommunityID"
      InsertMethod="SaveUnitTypes"
      UpdateMethod="SaveUnitTypes"
      &gt;
      &lt;SelectParameters&gt;          
          &lt;asp:Parameter DefaultValue="1" Name="CommunityID" /&gt;            
      &lt;/SelectParameters&gt;
      &lt;/asp:ObjectDataSource&gt;
  </code></pre>
  
  <p>Please help me out to make a sucessful insertion.</p>
  
  <p>Also in the Telerik documentation I saw them using <code>e.ite.item</code> index for getting the vdatakeyvalue but if I use it the index is always showing up as -1 so I used <code>editedItem.ItemIndex</code> and it works fine</p>
  
  <p>Thanks in advance</p>