private void Btn_FindStudent(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(TextBox1.Text) && string.IsNullOrEmpty(TextBox2.Text)) { MessageBox.Show("Search fields, Name or RollNo is empty."); return; } var studentBll = new StudentBll(); Student student = studentBll.GetStudentData(TextBox1.Text, TextBox2.Text); if (student == null) { MessageBox.Show("No such student exists."); return; } TextBox1.Text = student.Name; TextBox2.Text = student.RollNumber; TextBox3.Text = student.Address; TextBox4.Text = student.UserName; TextBox5.Text = student.Password; rollnumber = student.RollNumber; }