M
Me LK
I have a drop down menu with hard coded states. When the page is
viewed the top state automatically shows (Alabama). The state I need
to show is the one that is in the database not the top on the list.
Since I have hard coded the states to the datalist instead of pull
them from the database I am a bit confused as to how to display the
correct item.
My code behind (vb)
______________________________________________________________________
Dim connection As New SqlConnection(connectionString)
Dim Command As New SqlCommand("GetCustomer", Connection)
Command.CommandType = CommandType.StoredProcedure
Command.Parameters.Add("@CustomerID",
Context.Session("CustomerID"))
' extract existing customer details
connection.Open()
Dim customerReader As SqlDataReader = command.ExecuteReader()
customerReader.Read()
If Not customerReader("homeaddress").GetType() Is
GetType(DBNull) Then
txtFirstName.Text = customerReader("first")
txtLastName.Text = customerReader("Last")
txtStreetAddress.Text = customerReader("homeaddress")
txtStreetAddress2.Text = customerReader("homeaddress2")
txtCity.Text = customerReader("City")
State.DataTextField = customerReader("state") ********THIS
IS THE DROP DOWN MENU
________________________________________________________________
I am hard coding the drop down menu in this manner.
<asp:dropdownlist id="State" runat="server">
<asp:ListItem Value="AL">Alabama</asp:ListItem>
<asp:ListItem Value="AK">Alaska</asp:ListItem>
<asp:ListItem Value="AZ">Arizona</asp:ListItem>
<asp:ListItem Value="AR">Arkansas</asp:ListItem>
<asp:ListItem Value="CA">California</asp:ListItem>
<asp:ListItem Value="CO">Colorado</asp:ListItem>
Etc.......
____________________________________________________________________
The text boxes work find and pull the data from the database. The
dropdown list does not. It only shows the hard coded data. This is
probably something stupid and trivial but my brain is just not
working. Any suggestions appreciated.
LK
viewed the top state automatically shows (Alabama). The state I need
to show is the one that is in the database not the top on the list.
Since I have hard coded the states to the datalist instead of pull
them from the database I am a bit confused as to how to display the
correct item.
My code behind (vb)
______________________________________________________________________
Dim connection As New SqlConnection(connectionString)
Dim Command As New SqlCommand("GetCustomer", Connection)
Command.CommandType = CommandType.StoredProcedure
Command.Parameters.Add("@CustomerID",
Context.Session("CustomerID"))
' extract existing customer details
connection.Open()
Dim customerReader As SqlDataReader = command.ExecuteReader()
customerReader.Read()
If Not customerReader("homeaddress").GetType() Is
GetType(DBNull) Then
txtFirstName.Text = customerReader("first")
txtLastName.Text = customerReader("Last")
txtStreetAddress.Text = customerReader("homeaddress")
txtStreetAddress2.Text = customerReader("homeaddress2")
txtCity.Text = customerReader("City")
State.DataTextField = customerReader("state") ********THIS
IS THE DROP DOWN MENU
________________________________________________________________
I am hard coding the drop down menu in this manner.
<asp:dropdownlist id="State" runat="server">
<asp:ListItem Value="AL">Alabama</asp:ListItem>
<asp:ListItem Value="AK">Alaska</asp:ListItem>
<asp:ListItem Value="AZ">Arizona</asp:ListItem>
<asp:ListItem Value="AR">Arkansas</asp:ListItem>
<asp:ListItem Value="CA">California</asp:ListItem>
<asp:ListItem Value="CO">Colorado</asp:ListItem>
Etc.......
____________________________________________________________________
The text boxes work find and pull the data from the database. The
dropdown list does not. It only shows the hard coded data. This is
probably something stupid and trivial but my brain is just not
working. Any suggestions appreciated.
LK