using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
   
    protected void RadGrid1_DetailTableDataBind(object source, GridDetailTableDataBindEventArgs e)
    {
        GridTableView view = e.DetailTableView;
        view.HierarchyDefaultExpanded = false;
        view.Width = Unit.Percentage(100);
        if (view.Name == "Orders")
        {
            view.DataKeyNames = new string[] { "CustomerID", "OrderID" };
            view.DataSourceID = "SqlDataSource2";
            GridRelationFields fields = new GridRelationFields();
            fields.DetailKeyField = "CustomerID";
            fields.MasterKeyField = "CustomerID";
            view.ParentTableRelation.Add(fields);
        }
        if (view.Name == "OrderDetails")
        {
            view.DataKeyNames = new string[] { "OrderID" };
            view.DataSourceID = "SqlDataSource3";
            GridRelationFields fields = new GridRelationFields();
            fields.DetailKeyField = "OrderID";
            fields.MasterKeyField = "OrderID";
            view.ParentTableRelation.Add(fields);
        }
    }
}
