protected void Page_Load(object sender, EventArgs e) { IEnumerable <AllStudents> allStudents = AllStudents.GetAllStudents().Where(students => students.StudentGender == "Male"); GridView3.DataSource = allStudents; GridView3.DataBind(); }
public static List <AllStudents> GetAllStudents() { List <AllStudents> allStudents = new List <AllStudents>(); AllStudents allStudents1 = new AllStudents() { StudentID = 1, StudentAge = 12, StudentGender = "Male", StudentName = "Samu1" }; allStudents.Add(allStudents1); AllStudents allStudents2 = new AllStudents() { StudentName = "Samu2", StudentID = 2, StudentGender = "Female", StudentAge = 13 }; allStudents.Add(allStudents2); AllStudents allStudents3 = new AllStudents() { StudentAge = 14, StudentGender = "Male", StudentID = 5, StudentName = "Samu3" }; allStudents.Add(allStudents3); AllStudents allStudents4 = new AllStudents() { StudentName = "Samu6", StudentID = 22, StudentGender = "Female", StudentAge = 10 }; allStudents.Add(allStudents4); return(allStudents); }