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

public partial class _Default : System.Web.UI.Page 
{
    protected void RadSkinManager1_PreRender(object sender, EventArgs e)
    {
        RadComboBox skinChooser = RadSkinManager1.FindControl("SkinChooser") as RadComboBox;
        foreach (RadComboBoxItem item in skinChooser.Items)
        {
            if (item.Text == "Silk" || item.Text == "Glow" || item.Text == "BlackMetroTouch" || item.Text == "MetroTouch")
            {
                item.Visible = false;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //RadAjaxManager1.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(RadAjaxManager1_AjaxRequest);
        RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(RadGrid1_NeedDataSource);
    }

    //void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    //{
    //    if (e.Argument == "RebindLatePanel")
    //    {
    //        RadGrid1.Rebind();
    //    }
    //}

    void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
       
            RadGrid1.DataSource = SampleData;
      
    }

    public DataTable SampleData
    {
        get
        {
            if (Session["_data"] == null || !Page.IsPostBack)
            {
                System.Data.DataTable table = new System.Data.DataTable();
                table.Columns.Add("ID", Type.GetType("System.Int32"));
                table.Columns.Add("Name", Type.GetType("System.String"));
                table.Columns.Add("Date", Type.GetType("System.DateTime"));
                table.Columns.Add("Value", Type.GetType("System.Double"));

                Random rand = new Random();

                for (int i = 0; i < 10; i++)
                {
                    table.Rows.Add(i,
                                   "Item " + i.ToString(),
                                   DateTime.Today.AddDays(-10).AddDays(rand.NextDouble() * 20),
                                   rand.NextDouble() * 1000);
                }

                Session["_data"] = table;
            }

            return (DataTable)Session["_data"];
        }
    }


}
