Detect if the user has selected an item
Posted on 2004-09-30
Hi team, I am looking for a solution that will detect if the user has <u>not</u> choosen an item from a list box. The code below is what I have come up with and does not seem to provide me with the answer I am looking for.
public void GetSelections(ListBox _LBox) //Comments are same as above
StringBuilder sb1 = new StringBuilder("");
StringBuilder sb2 = new StringBuilder("");
for(int i=0; i < _LBox.Items.Count; i++)
sb1.Append(_LBox.Items[i].Text); //Return more than one Location, if selected
sb1.Append(","); //split muliple selections with ','.
sb2.Append(_LBox.Items[i].Value); //Return more than one Location id.
sb2.Append(","); //split multiple selections with ','.
_sbLocationIDs = null;
_sbLocationsText = null;
lblLocations.Text = "None Selected";
_sbLocationIDs = sb2;
_sbLocationsText = sb1;
lblLocations.Text = "Selected Locations: " + sb1.ToString(); //Set the label equal to selections.