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

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

    }
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        CreateHeaderControls(e);
    }

    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        CreateHeaderControls(e);
    }

    void check_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox check = (CheckBox)sender;
        GridGroupHeaderItem groupHeader = (GridGroupHeaderItem)check.NamingContainer;
        GridItem[] children = groupHeader.GetChildItems();
        foreach (GridItem child in children)
        {
            if (child is GridDataItem)
            {
                ((child as GridDataItem)["CheckBox1"].Controls[0] as CheckBox).Checked = (sender as CheckBox).Checked;
            }
        }
    }
    private void CreateHeaderControls(GridItemEventArgs e)
    {
        if (e.Item is GridGroupHeaderItem)
        {
            GridGroupHeaderItem item = e.Item as GridGroupHeaderItem;
            DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
            CheckBox check = new CheckBox();
            check.AutoPostBack = true;
            check.ID = "CheckAll";
            check.Text = "Check/Uncheck CheckBox1 column";
            check.CheckedChanged += new EventHandler(check_CheckedChanged);
            item.DataCell.Controls.Add(check);

        }
    }

}
