Try opening your can.ascx.designer.cs file. Do you see an entry for ComAreaNet in here? If so, then comment out the one you have declared in your can.ascx.cs file (you don't need it both places).
I think the real root of your problem here, is you shouldn't be doing anything in InitializeComponent. The controls aren't initialized completely until this method exits. I'd suggest moving your call to FetchCans() into the PageLoad event for the page.
That way you know that all the controls have completed their initialization (and been assigned IDs, etc.).
Hope this helps!
Jon
InitializeComponent
Hope this helps!
Jon
If I was able to help, please mark this post as Answer.
JByrd2007
Member
447 Points
93 Posts
Re: Object reference not set to instance of an object error
Jan 08, 2009 03:07 PM|LINK
Try opening your can.ascx.designer.cs file. Do you see an entry for ComAreaNet in here? If so, then comment out the one you have declared in your can.ascx.cs file (you don't need it both places).
I think the real root of your problem here, is you shouldn't be doing anything in InitializeComponent. The controls aren't initialized completely until this method exits. I'd suggest moving your call to FetchCans() into the PageLoad event for the page. That way you know that all the controls have completed their initialization (and been assigned IDs, etc.).
Hope this helps!
Jon
InitializeComponent
Jon
If I was able to help, please mark this post as Answer.