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 
{
    bool InsertCommand = false;
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        RadGrid1.ItemCommand+=new Telerik.Web.UI.GridCommandEventHandler(RadGrid1_ItemCommand); 
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.PerformInsertCommandName)
        {
            InsertCommand = true;
        }
    }


    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (InsertCommand)
        {
            RadGrid1.Items[0].Expanded = true;
            foreach (GridTableView tableView in RadGrid1.Items[0].ChildItem.NestedTableViews)
            {
                tableView.InsertItem();
            }
        }
    }


}
