G
Guest
I have tried this with no luck. What i want is to show the selected item on
the first post. the selected item is NY but the first in the list shows as
selected.
If Page.IsPostBack = False Then
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("Get_States",
myConnection)
Dim Statetypes As SqlDataReader
myConnection.Open()
Statetypes = myCommand.ExecuteReader
StateCode.DataSource = Statetypes
StateCode.DataTextField = "State"
StateCode.DataValueField = "StateId"
' Databind and display the list of favorite product items
StateCode.DataBind()
myConnection.Close()
Dim i As Integer
For i = 0 To StateCode.Items.Count - 1
Dim Statechk As String = StateCode.Items(i).Value
Dim chk = StateCode.DataValueField
If Statechk = customerDetails.State Then
StateCode.SelectedItem.Selected = True
End If
Next
end if
the first post. the selected item is NY but the first in the list shows as
selected.
If Page.IsPostBack = False Then
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myCommand As SqlCommand = New SqlCommand("Get_States",
myConnection)
Dim Statetypes As SqlDataReader
myConnection.Open()
Statetypes = myCommand.ExecuteReader
StateCode.DataSource = Statetypes
StateCode.DataTextField = "State"
StateCode.DataValueField = "StateId"
' Databind and display the list of favorite product items
StateCode.DataBind()
myConnection.Close()
Dim i As Integer
For i = 0 To StateCode.Items.Count - 1
Dim Statechk As String = StateCode.Items(i).Value
Dim chk = StateCode.DataValueField
If Statechk = customerDetails.State Then
StateCode.SelectedItem.Selected = True
End If
Next
end if