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;
using System.Collections;

public partial class _Default : System.Web.UI.Page 
{

    protected void Page_Init(object sender, EventArgs e)
    {
        RadGrid1.DetailTableDataBind += new Telerik.Web.UI.GridDetailTableDataBindEventHandler(RadGrid1_DetailTableDataBind);
        RadGrid1.ItemCommand += new Telerik.Web.UI.GridCommandEventHandler(RadGrid1_ItemCommand);
    }

    protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.UpdateCommandName && e.Item.OwnerTableView.Name == "DetailTable")
        {
            Hashtable newValues = new Hashtable();
            ((GridEditableItem)e.Item).ExtractValues(newValues);

            SqlDataSource2.UpdateParameters["OrderID"].DefaultValue = ((GridEditableItem)e.Item).GetDataKeyValue("OrderID").ToString();
            SqlDataSource2.UpdateParameters["OrderDate"].DefaultValue = newValues["OrderDate"].ToString();
            SqlDataSource2.UpdateParameters["ShipCountry"].DefaultValue = newValues["ShipCountry"].ToString();

            SqlDataSource2.Update();
        }
    }

    protected void RadGrid1_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
    {
        SqlDataSource2.SelectParameters["CustomerID"].DefaultValue = e.DetailTableView.ParentItem.GetDataKeyValue("CustomerID").ToString();
        e.DetailTableView.DataSource = SqlDataSource2.Select(new DataSourceSelectArguments());
    }

}
