using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;

public partial class _Default : System.Web.UI.Page
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        RadGrid1.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
        RadGrid1.ItemCreated += new Telerik.Web.UI.GridItemEventHandler(RadGrid1_ItemCreated);
        RadGrid1.ItemDataBound += new GridItemEventHandler(RadGrid1_ItemDataBound);
    }

    void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            RadioButton button = item["BoolItem"].FindControl("RadioButton1") as RadioButton;
            button.Checked = (bool)(item.DataItem as DataRowView).Row["BoolItem"];
        }
    }

    void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            item["BoolItem"].Controls.Clear();
            RadioButton button = new RadioButton();
            button.ID = "RadioButton1";
            item["BoolItem"].Controls.Add(button);
        }
    }

    void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("ID");
        table.Columns.Add("Item");
        table.Columns.Add("BoolItem", typeof(Boolean));
        for (int i = 1; i < 8; i++)
        {
            if (i > 5)
                table.Rows.Add(i, "Item" + i.ToString(), true);
            else
                table.Rows.Add(i, "Item" + i.ToString(), false);
        }
        RadGrid1.DataSource = table;
    }
}
