private void btnPrint_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count > 0) { int myorder = int.Parse(this.dataGridView1.SelectedRows[0].Cells[0].Value.ToString()); DALStudent myStudent = new DALStudent(); Candidate cand = myStudent.ReadyQueryWithKey(myorder.ToString()); if (cand != null) { DoPrint(cand); } } }