using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

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

public partial class Default : System.Web.UI.Page 
{
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
    }

    protected void RadGrid1_DetailTableDataBind(object source,
                      GridDetailTableDataBindEventArgs e)
    {
        // make sure this is this is the right detail table
        if (e.DetailTableView.DataSourceID == "")
        {
            GridDataItem masterItem = (GridDataItem)e.DetailTableView.ParentItem;
            SqlConnection conn =
               new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand =
               new SqlCommand("Select * from [Orders] where CustomerID = '" +
                        masterItem.GetDataKeyValue("CustomerID").ToString()+"'", conn);
            DataTable table = new DataTable();
            conn.Open();
            try
            {
                da.Fill(table);
            }
            finally
            {
                conn.Close();
            }
            e.DetailTableView.DataSource = table;
        }
    } 
}
