This is a migrated thread and some comments may be shown as answers.

Radmenu Datasource Error

1 Answer 31 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Praveen
Top achievements
Rank 1
Praveen asked on 20 Feb 2012, 11:29 AM
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 

1 Answer, 1 is accepted

Sort by
0
Kate
Telerik team
answered on 20 Feb 2012, 11:52 AM
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 >>
Tags
Menu
Asked by
Praveen
Top achievements
Rank 1
Answers by
Kate
Telerik team
Share this question
or