private List <string> getEmpnames() { EmpComponent db = new EmpComponent(); var table = db.GetEmployees(); List <string> names = new List <string>(); foreach (DataRow row in table.Rows) { names.Add(row["EmpName"].ToString()); } return(names); }
private void onSelected(object sender, SelectionChangedEventArgs e) { var selectedName = lstNames.SelectedItem.ToString(); var db = new EmpComponent(); var data = db.GetEmployees(); foreach (DataRow row in data.Rows) { if (row[1].ToString() == selectedName) { txtId.Text = row[0].ToString(); txtName.Text = row[1].ToString(); txtAddress.Text = row[2].ToString(); txtSalary.Text = row[3].ToString(); return;//exit... } } }