Radmenu Datasource Error

2 posts, 0 answers
  1. Praveen
    Praveen avatar
    3 posts
    Member since:
    Feb 2012

    Posted 20 Feb 2012 Link to this post

    Hi All,

    I am just testing radmenu as per the sample code provided by telerik
    http://www.telerik.com/help/aspnet-ajax/menu-datatable-view.html 
     
    i have copied each and every line from the above url, but when i say RadMenu1.DataSource = CreateTestTable();
    it throws error saying Object reference not set to an instance of an object.

    i have pasted my code below for your reference.

    <telerik:RadMenu runat="server" ID="RadMenu1"  Style="z-index: 3" EnableRoundedCorners="true"   
    EnableShadows="true" EnableTextHTMLEncoding="true" >
    </telerik:RadMenu>
           
    protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
               FillRadMenu();
            }
         }
     
    protected void FillRadMenu()
        {
           RadMenu1.DataSource = CreateTestTable();
           RadMenu1.DataFieldID = "ID";
           RadMenu1.DataFieldParentID = "ParentID";
           RadMenu1.DataTextField = "Text";
           RadMenu1.DataValueField = "ID";
           RadMenu1.DataNavigateUrlField = "URL";
           RadMenu1.DataBind(); 
        }
     
      private DataTable CreateTestTable()
        {
            DataTable table = new DataTable();
            table.Columns.Add("ID");
            table.Columns.Add("ParentID");
            table.Columns.Add("Text");
            table.Columns.Add("URL");
            table.Columns.Add("Tooltip");
            table.Rows.Add(new string[] { "1", null, "root 1", "root1.aspx", "root 1 tooltip" });
            table.Rows.Add(new string[] { "2", null, "root 2", "root2.aspx", "root 1 tooltip" });
            table.Rows.Add(new string[] { "3", "1", "child 1.1", "child11.aspx", "child 1.1 tooltip" });
            table.Rows.Add(new string[] { "4", "1", "child 1.2", "child12.aspx", "child 1.2 tooltip" });
            table.Rows.Add(new string[] { "5", "1", "child 1.3", "child13.aspx", "child 1.3 tooltip" });
            table.Rows.Add(new string[] { "6", "5", "child 1.3.1", "child131.aspx", "child 1.3.1 tooltip" });
            table.Rows.Add(new string[] { "7", "5", "child 1.3.2", "child132.aspx", "child 1.3.2 tooltip" });
            table.Rows.Add(new string[] { "8", "5", "child 1.3.3", "child133.aspx", "child 1.3.3 tooltip" });
            return table;
        }


    your help greatly appreciated..awaiting your reponses..

    Regards,
    Praveen 
  2. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 20 Feb 2012 Link to this post

    Hello Praveen,

    I tested the code and it seems to be working correctly from my side. I also attached my testing page for your reference.

    All the best,
    Kate
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top