This example shows the in-line data editing feature of Telerik Grid for ASP.NET MVC. In this example the grid is using web service binding.

To enable editing you need perform the following:

  1. Define a command column for the "Edit" and "Delete" commands:
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.ContactName).Width(360);
                columns.Bound(c => c.Country).Width(120);
                columns.Bound(c => c.Address).Width(200);
                columns.Bound(c => c.BirthDay).Width(130).Format("{0:d}");
                columns.Command(commands =>
                {
                    commands.Edit();
                    commands.Delete();
                }).Width(200);
                
            })
    %>
    
  2. If you want to enable inserting of new records configure the grid toolbar:
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .ToolBar(commands => commands.Insert())
            .Columns(columns =>
            {
                //omitted for brevity
            })
    %>
    
  3. Specify the property which uniquely identifies the data record. In this case it is CustomerID:
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .ToolBar(commands => commands.Insert())
            .DataKeys(keys => keys.Add(c => c.CustomerID))
            .Columns(columns =>
            {
                //omitted for brevity
            })
    
  4. Specify the action methods which will delete, insert or save data records.
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .ToolBar(commands => commands.Insert())
            .DataKeys(keys => keys.Add(c => c.CustomerID))
            .DataBinding(dataBinding => dataBinding
                .WebService()
                    .Select("~/Models/Customers.asmx/GetCustomers")
                    .Update("~/Models/Customers.asmx/SaveCustomer")
                    .Insert("~/Models/Customers.asmx/InsertCustomer")
                    .Delete("~/Models/Customers.asmx/DeleteCustomer")
            )
            .Columns(columns =>
            {
                //omitted for brevity
            })