Click here to Skip to main content
15,912,072 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all

Please check my code


C#
MainMenu first_menu = new MainMenu();
this.Menu = first_menu;

MenuItem[] secondMenu = new MenuItem[2];
MenuItem menu = new MenuItem(row["CategoryId"].ToString());
secondMenu[0] = menu;

MenuItem Parent_menu = new MenuItem( row["Name_tb"].ToString(), secondMenu);


error happening as object reference does not set to an instance of object

What may be the reason,how to pass value field of menu item in windows application other than this method

Thanks in Advance
Posted
Updated 1-Mar-12 22:47pm
v2
Comments
Bojjaiah 2-Mar-12 4:51am    
check it with debugger.there is no results or came!
jai000 2-Mar-12 5:06am    
Which line is throwing exception?
amritha444 2-Mar-12 5:22am    
hi
this line is throwing exception
MenuItem Parent_menu = new MenuItem( row["Name_tb"].ToString(), secondMenu);
ZurdoDev 2-Mar-12 10:37am    
So, either row["Name_tb"] is null or secondMenu is null. Just use the debugger.
johannesnestler 2-Mar-12 5:22am    
something is null - I'd guess your row-Value is null or empty. check with the debuger, or give full exception text here - (look at the stack trace which line causes the error) You can also split your code and use some "intermediate" variables (e.g. string strID = row["CategoryId"].ToString();) for debugging so you can find out which statement causes the exception

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900