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;

public partial class _Default : System.Web.UI.Page
{
  private DataTable CreateTable()
  {

    DataTable tbl = new DataTable();
    tbl.Columns.Add( "ID" );
    tbl.Columns.Add( "Text" );
    tbl.Columns.Add( "Value" );
    tbl.Columns.Add( "ParentID" );
    tbl.Columns.Add( "NavigateUrl" );

    tbl.Rows.Add( "1", "News", "You clicked News", null );
    tbl.Rows.Add( "2", "Sports", "You clicked Sports", null );
    tbl.Rows.Add( "3", "Events", "You clicked Events", null );

    tbl.Rows.Add( "4", "CNN", "You clicked CNN", 1, "http://www.cnn.com" );
    tbl.Rows.Add( "5", "NBC", "You clicked NBC", 1, "http://www.nbc.com" );
    tbl.Rows.Add( "6", "Fox", "You clicked Fox", 1, "http://www.fox.com" );

    tbl.Rows.Add( "7", "ESPN", "You clicked ESPN", 2, "http://www.espn.com" );
    tbl.Rows.Add( "8", "USA Hockey", "You clicked USA Hockey", 2, "http://www.usahockey.com" );

    tbl.Rows.Add( "9", "Oscar Awards", "You clicked Oscar Awards", 3, "http://www.oscars.com" );
    tbl.Rows.Add( "10", "MTV Movie Awards", "You clicked MTV Movie Awards", 3, "http://www.mtv.com" );

    return tbl;
  }

  protected void Page_Load( object sender, EventArgs e )
  {
    RadMenu1.DataSource = CreateTable();
    RadMenu1.DataFieldID = "ID";
    RadMenu1.DataTextField = "Text";
    RadMenu1.DataValueField = "Value";
    RadMenu1.DataFieldParentID = "ParentID";
    RadMenu1.DataNavigateUrlField = "NavigateUrl";
    RadMenu1.DataBind();
  }

  protected void RadMenu1_ItemClick( object sender, Telerik.WebControls.RadMenuEventArgs e )
  {
    Label1.Text = e.Item.Value;
  }
  protected void RadMenu1_ItemCreated( object sender, Telerik.WebControls.RadMenuEventArgs e )
  {
    Label2.Text += e.Item.Text + " has been added" + "<br/>";
  }
  protected void RadMenu1_ItemDataBound( object sender, Telerik.WebControls.RadMenuEventArgs e )
  {
    DataRowView row = (DataRowView)e.Item.DataItem;
    e.Item.Text = row["Text"].ToString() + " from IDB";
  }
}


