protected void Button1_Click(object sender, EventArgs e) { int i = -9999; ListBox1.Items.Clear(); Label5.Text = ""; Label7.Text = ""; Label9.Text = ""; Label11.Text = ""; Label13.Text = ""; Label15.Text = ""; Label17.Text = ""; Label19.Text = ""; Label21.Text = ""; Label23.Text = ""; Label25.Text = ""; Label27.Text = ""; Label29.Text = ""; Label31.Text = ""; Label33.Text = ""; Label35.Text = ""; Label37.Text = ""; Label39.Text = ""; Label41.Text = ""; //if (TextBox1.Text.Equals(null) || TextBox1.Text.Equals("") || TextBox2.Text.Equals(null) || TextBox2.Text.Equals("")) //{ // ListBox1.Items.Add("No Matches"); //} if (TextBox1.Text.Equals("") && TextBox2.Text.Equals("")) { ListBox1.Items.Add("No Matches"); } else { if (TextBox1.Text == "*" || TextBox2.Text == "*") { if (TextBox1.Text == "*") { TextBox1.Text = ""; } if (TextBox2.Text == "*") { TextBox2.Text = ""; } else { TextBox2.Text = ""; } } //i = gml.GetMembers(TextBox1.Text, TextBox2.Text, TextBox3.Text); #region [Old code for seraching which getting all the athlet] //i = gml.GetMembers(TextBox1.Text, TextBox2.Text, ""); //if (gml.GuidMatch.Count.Equals(0)) //{ // //MessageBox.Show("No Matches"); // ListBox1.Items.Add("No Matches"); //} //else //{ // int x = 0; // string ListBoxItem = ""; // foreach (string MemberGuid in gml.GuidMatch) // { // ListBoxItem = gml.FirstNameMatch[x].ToString() + " " + gml.LastNameMatch[x].ToString() + ", " + gml.EmailMatch[x].ToString() + ", " + gml.UsernameMatch[x].ToString(); // ListBox1.Items.Add(ListBoxItem); // ListBox1.Items[x].Value = gml.CustomerIdMatch[x].ToString() + "," + gml.UsernameMatch[x].ToString() + "|" + gml.EmailMatch[x].ToString(); // x++; // } //} #endregion [Old code for seraching which getting all the athlet] #region [new code for seraching which getting all the athlet of particular teacher] if (Page.User.Identity.IsAuthenticated) { DataTable dt = new DataTable(); teacher = DataRepository.TeacherProvider.GetByAspnetMembershipUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()))[0]; DataTable dstecher = _sprintAthleteEdit.GetMembers(TextBox1.Text, TextBox2.Text, teacher.TeacherId); if (dstecher != null) { int x = 0; string ListBoxItem = ""; foreach (DataRow row in dstecher.Rows) { DataRow r = dt.NewRow(); string userrolename = string.Empty; int customerid = Convert.ToInt32(row["CustomerId"]); AthleteSearched = DataRepository.CustomerProvider.GetByCustomerId(customerid); Guid MemGuid = new Guid(AthleteSearched.AspnetMembershipUserId.ToString()); MembershipUser user = Membership.GetUser(MemGuid); string[] userrole = Roles.GetRolesForUser(user.UserName); userrolename = userrole[0]; if (userrolename == "Athletes") { ListBoxItem = row["FirstName"].ToString() + " " + row["LastName"].ToString() + ", " + row["Email"].ToString(); ListBox1.Items.Add(ListBoxItem); ListBox1.Items[x].Value = row["CustomerID"].ToString(); x++; } } if (ListBox1.Items.Count == 0) { ListBox1.Items.Add("No Matches"); } } else { ListBox1.Items.Add("No Matches"); } } #endregion [new code for seraching which getting all the athlet of particular teacher] } }