I have a validation method with 5 validation elements to it, 4 of which work as intended but 1 does not, question is why not?
The issue I have is with Validating “CompetitionCourse”. I want the IsValid to be true only if the combobox cbCourseRound1 is not blank. At the moment this is validating regardless of this combobox being blank or populated. All other validations are working,
private bool Validate(Competition compSetup)
{
string CompetitionName = compSetup._CompetitionName;
int CompetitionFormat = compSetup._CompetitionFormatId;
string CompetitionGender = cbGenderOfCompetiton.Text;
string CompetitionMarker = cbMarker.Text;
string CompetitionCourse = cbCourseRound1.Text;
if (!CompetitionName.Equals(string.Empty) && !CompetitionGender.Equals("Mixed") && CompetitionFormat.Equals(1) && !CompetitionCourse.Equals(string.Empty) &&
((CompetitionGender.Equals("Female") && CompetitionMarker.Equals("Red")) || (!CompetitionGender.Equals("Female") && !CompetitionMarker.Equals("Red"))))
{
IsValid = true;
}
else
{
IsValid = false;
}
return IsValid;
}
depends on what’s in
CompetitionCourse. You’ll have to check that yourself by debugging your code.You’d be better off making explicitly sure that
CompetitionCoursecontainsnullif the ComboBox text field is blank (because I suspect it contains “”):