protected void ddlContacts_SelectedIndexChanged(object sender, EventArgs e) { try { ContactsBL contactsBL = new ContactsBL(); int id = int.Parse(ddlContacts.SelectedValue); contact = contactsBL.GetContact(id); populateForm(); lblMessage.Text = ""; } catch (Exception ex) { lblMessage.Text = ex.Message; } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { try { ContactsBL contactsBL = new ContactsBL(); int rowindex = dataGridView1.CurrentCell.RowIndex; int id = int.Parse(dataGridView1.Rows[rowindex].Cells["ContactID"].Value.ToString()); contact = contactsBL.GetContact(id); populateForm(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }