using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        RadGrid1.ItemCommand += new Telerik.Web.UI.GridCommandEventHandler(RadGrid1_ItemCommand);
        RadGrid1.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);

    }

    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        RadGrid1.DataSource = SqlDataSource1.Select(new DataSourceSelectArguments());
    }

    protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.InitInsertCommandName)
        {
            e.Canceled = true;
            RadGrid1.EditIndexes.Clear();
            e.Item.OwnerTableView.EditFormSettings.UserControlName = "EditFormControl.ascx";
            e.Item.OwnerTableView.InsertItem(); 
        }
    }
}
