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.ItemCommand += RadGrid1_ItemCommand;
    }

    void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "ExpandCollapse")
        {
            if ((e.Item as GridDataItem).Expanded == false)
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "LoadMapScript", string.Format("LoadMap({0},{1})", 42.696804,23.328781), 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 < 100; i++)
        {
            table.Rows.Add(i.ToString(), "item" + i.ToString(), DateTime.Now.AddDays(i));
        }

        RadGrid1.DataSource = table;
    }
}
