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

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

        RadGrid1.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
    }

    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        string script = string.Format("gridID = '{0}';", RadGrid1.ClientID);
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "gridid", script, true);
    }

    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("Date");
        for (int i = 1; i < 10; i++)
        {
            table.Rows.Add(i, "item" + i.ToString(), DateTime.Now.AddDays(i));
        }

        RadGrid1.DataSource = table;
    }
}