Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System.NullReferenceException Error

Status
Not open for further replies.

jen89

Programmer
Aug 16, 2001
105
US
I am having a problem with a System.NullReferenceException error. I have a single page with about 10 listbox pairs, and a set of << and >> buttons. The user should be able to use the buttons to select items from the list on the left and move them to the list on the right. I have a tree, and depending on the node that the user picks, only one listbox pair is actually visible at a time. I would like to pass the visible listbox in as a parameter to a single Move function. I could not figure this out, so I tried declaring a listbox variable for the To and From listboxs, and setting them equal to the appropriate listboxes during the tree's onClick event. My debugging shows that this works, but I am having a problem when I fire the move_onclick event. Somewhere in between the tree onclick event's end and the move_onclick, the variables are being set back to nothing. Naturally, when I try to reference them in the move sub, I get the System.NullReferenceException Error. Ex:
Code:
List_S.Items.Add(New ListItem(List_L.SelectedItem.Text, List_L.SelectedItem.Value))
Does anyone have any idea where I am going wrong? I know that the variables are being set properly at some point. I only access the variable in the tree_onclick and the Move_Onclick. Thanks in advance,

Jen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top