We still have to add the code so that when a user selects an
item in the drop down list the system will retrieve the record and display the
information on the web page. This will be done in the SelectedIndexChanged
event.
1.
Switch back to Design view and double click on the Users drop down list.
This should create the SelectedIndexChanged event handler.
2.
Add the following code
txtFirstName.Text = "";
txtLastName.Text = "";
lblInserted.Text = "";
lblUpdated.Text = "";
if (ddlUsers.SelectedValue != "")
{
int userAccountId = Convert.ToInt32(ddlUsers.SelectedValue);
UserAccountEO userAccount = new UserAccountEO();
if (userAccount.Select(userAccountId))
{
txtFirstName.Text = userAccount.FirstName;
txtLastName.Text = userAccount.LastName;
lblInserted.Text = userAccount.InsertDate.ToString();
lblUpdated.Text = userAccount.UpdateDate.ToString();
}
}
This code calls the Select method of the UserAccountEO
object to grab the record and load the properties in the business object. The
textboxes and labels are set to the properties of the object that was returned.
If you run the project now you should be able to pull up the
records that were added previously and then update them.