Before the form is submitted, all the listbox items are selected.
What is the best way to access the dynamically added items on the server side?
I have no problem accessing items that were previously added on the server side. They show up as ListIems in the SelectedIndexChanged event. The dynamically added items do not.
One way I have found is to loop through a NameValueCollection searching for the appropriate key value, e.g. "Box1", and then get the values.
For example, in Page_Load:
NameValueCollection coll1 = Request.Form;
String arr1 = coll1.AllKeys;
for (loop1 = 0; loop1<arr1.Length; loop1++)
if (arr1[loop1] == "box1") //is this the key I'm looking for?
String arr2 = coll1.GetValues(arr1[loop1]); // Get all values under this key.
for (loop2 = 0; loop2 < arr2.Length; loop2++)
This works, but isn't there something more straightforward? Is there anyway to access Box1 items more directly?
I am new to ASP.NET and have no idea what I am doing. I hope this means easy points for someone.