Re: Mark A selected item on first post. please help
From: Ken Dopierala Jr. (kdopierala2_at_wi.rr.com)
Date: 10/04/04
- Next message: Cor Ligthert: "Re: Installing .NET on web server"
- Previous message: Mike S.: "SystemParametersInfo Failing in VB.net"
- In reply to: Stanley J Mroczek: "Mark A selected item on first post. please help"
- Next in thread: Ken Dopierala Jr.: "Re: Mark A selected item on first post. please help"
- Reply: Ken Dopierala Jr.: "Re: Mark A selected item on first post. please help"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 4 Oct 2004 15:00:12 -0500
Hi,
Your problem is in this code:
> 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
The line below doesn't do anything new. It is constantly setting the
selected item to be selected again.
StateCode.SelectedItem.Selected = True
You would want to do something like this in its place:
StateCode.Items(i).Selected = True
Good luck! Ken.
-- Ken Dopierala Jr. For great ASP.Net web hosting try: http://www.webhost4life.com/default.asp?refid=Spinlight If you sign up under me and need help, email me. "Stanley J Mroczek" <StanleyJMroczek@discussions.microsoft.com> wrote in message news:CB09FE13-FDA1-4496-A2A9-866611789EEC@microsoft.com... > 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 >
- Next message: Cor Ligthert: "Re: Installing .NET on web server"
- Previous message: Mike S.: "SystemParametersInfo Failing in VB.net"
- In reply to: Stanley J Mroczek: "Mark A selected item on first post. please help"
- Next in thread: Ken Dopierala Jr.: "Re: Mark A selected item on first post. please help"
- Reply: Ken Dopierala Jr.: "Re: Mark A selected item on first post. please help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|