private void btnfind_Click(object sender, EventArgs e) { try { if (txtfind.Text == "") { MessageBox.Show("Please Enter LeveID ", "Finding", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { String levID = txtfind.Text; DataSet ds = ldal.Find_Leave(levID); DataRow row; row = ds.Tables[0].Rows[0]; foreach (DataRow rows in ds.Tables[0].Rows) { txtleaveid.Text = rows["Leave_Id"].ToString(); cmbemp.Text = rows["Emp_Id"].ToString(); dateTimePicker1.Text = rows["App_Date"].ToString(); dateTimePicker2.Text = rows["Res_Date"].ToString(); cmbtype.Text = rows["Type"].ToString(); } } } catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); } }