msurfingworld
New Member
I am trying to check that an item doesn't already exist in a list box before I add the new item.\[code\] if (TeamNameTextBox.Text != "") { if (TeamNameListBox.Items.FindByValue(TeamNameListBox.Text) == null) { TeamNameListBox.Items.Add(TeamNameTextBox.Text); TeamNameTextBox.Text = ""; int teamCountUpdate = TeamNameListBox.Items.Count; if (teamCountUpdate == 1) { TeamCount.Text = teamCountUpdate.ToString() + " Team"; } else { TeamCount.Text = teamCountUpdate.ToString() + " Teams"; } } else { AddTeamSeasonError.Text = "This team has already been added"; } } else { AddTeamSeasonError.Text = "Please select a team"; }\[/code\]I have got it to check if the text box is blank, but I need to check that the item a user is trying to add is not already in the the list box.I have tried the line: \[code\]if (TeamNameListBox.Items.FindByValue(TeamNameListBox.Text) == null)\[/code\]But that doesn't work, any suggestions on how I can do the check?