protected void lstAuthor_SelectedIndexChanged(object sender, EventArgs e) { DataTable table = AuthorAccess.GetAuthorInfoByID(lstAuthor.SelectedValue); try { foreach (DataRow row in table.Rows) { txtID.Text = row["au_id"].ToString(); txtFirstName.Text = row["au_fname"].ToString(); txtLastName.Text = row["au_lname"].ToString(); txtPhone.Text = row["phone"].ToString(); txtAddress.Text = row["address"].ToString(); txtCity.Text = row["city"].ToString(); txtState.Text = row["state"].ToString(); txtZip.Text = row["zip"].ToString(); chkContract.Checked = (bool)row["contract"]; lblResults.Text = ""; } } catch (Exception err) { lblResults.Text = "Error getting author. " + err.Message; } }
protected void lstAuthor_SelectedIndexChanged(object sender, EventArgs e) { //This method retrieves all of the attributes of the selected author from the database and //populates the controls with these values //See page 455 DataTable table = AuthorAccess.GetAuthorInfoByID(lstAuthor.SelectedValue); DataRow row = table.Rows[0]; txtID.Text = row["au_id"].ToString(); txtFirstName.Text = row["au_fname"].ToString(); txtLastName.Text = row["au_lname"].ToString(); txtPhone.Text = row["phone"].ToString(); txtAddress.Text = row["address"].ToString(); txtCity.Text = row["city"].ToString(); txtState.Text = row["state"].ToString(); txtZip.Text = row["zip"].ToString(); chkContract.Checked = (bool)row["contract"]; lblResults.Text = ""; }