object reference does not set to an instance of object

Posted by Amritha444 under C# on 3/2/2012 | Points: 10 | Views : 1311 | Status : [Member] | Replies : 4
Hi all

Please check my code


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




Responses

Posted by: CGN007 on: 3/5/2012 [Member] Silver | Points: 25

Up
0
Down
Here secondMenu[1] is unassigned,that's the problem...
Please give more details about the scenario,Hope I can help...

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 3/5/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Could you upload your code ?Please tell me .what is the purpose of row using in your code?


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Blueskysinger on: 3/7/2012 [Member] Starter | Points: 25

Up
0
Down
i dont follow you. do you mean like a barcode generator?like this?http://www.keepautomation.com/csharp_barcode/2d_barcodes.html

Anna White

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 3/7/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi Amitha, Try this

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

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

secondMenu[1] = new MenuItem("");

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


Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Amritha444, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response