ComputerNovice
Baseband Member
- Messages
- 22
I've created an array at the top of my C# class, in the code behind the page:
List<Server> ServerArray = new List<Server>();
When I attempt to run the Insert button click method, a new server object is successfully added to the ArrayList and is, afterwards, displayed in the Listbox. See below:
ServerArray.Add( new Server(strserverName, strSerialNum));
int index = ServerArray.Count - 1;
ServerListBox.Items.Add(ServerArray[index].MName + ServerArray[index].MSerialNumber.ToUpper());
My problem is that once I click the Insert button again, to add another server, it appears as though the ArrayList clears itself of the previous reference and starts all over from an index of 0 again, while the Listbox retains the previous entry and displays the additional server.
Is the scope of the Insert button Click Method causing the ArrayList to clear itself, once that method ends? I thought, that since the ArrayList has global scope, the references would remain.
List<Server> ServerArray = new List<Server>();
When I attempt to run the Insert button click method, a new server object is successfully added to the ArrayList and is, afterwards, displayed in the Listbox. See below:
ServerArray.Add( new Server(strserverName, strSerialNum));
int index = ServerArray.Count - 1;
ServerListBox.Items.Add(ServerArray[index].MName + ServerArray[index].MSerialNumber.ToUpper());
My problem is that once I click the Insert button again, to add another server, it appears as though the ArrayList clears itself of the previous reference and starts all over from an index of 0 again, while the Listbox retains the previous entry and displays the additional server.
Is the scope of the Insert button Click Method causing the ArrayList to clear itself, once that method ends? I thought, that since the ArrayList has global scope, the references would remain.