I have a repeater where I have a column with checkboxes and one column with gender which i populate with database value.
I want to find out if user has selected multiple checkboxes of same gender e.g. male if so do something otherwise If a user selects multiple checkboxes with a mixture of male and female then do something else.
so far I was thinking to add this to a list and then see if list has same values but not sure if it is best idea here is my code (I have a hidden field to get gender ), I am running this on click event of a button:
foreach (RepeaterItem rptItem in myrepeater.Items)
{
hiddenGender = rptItem.FindControl("hiddenGender") as HiddenField;
if (Convert.ToInt32(hiddenGender.Value) == 0)
{
gender.Add(0);
}
else if (Convert.ToInt32(hiddenGender.Value) == 1)
{
gender.Add(1);
}
else if (Convert.ToInt32(hiddenGender.Value) == 2)
{
gender.Add(2);
}
}
ps without usage of linq as it is framework 2.0
got it, here is the code to maybe help others(first I get the first item and see if it matches next item) :