Re: Mark A selected item on first post. please help

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Dopierala Jr. (kdopierala2_at_wi.rr.com)
Date: 10/04/04


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
>


Relevant Pages

  • Re: Mark A selected item on first post. please help
    ... an Exit For to exit you from the loop: ... "Ken Dopierala Jr." ... > Good luck! ... >> Dim myConnection As SqlConnection = New ...
    (microsoft.public.dotnet.general)
  • Mark A selected item on first post. please help
    ... I have tried this with no luck. ... the first post. ... Dim myConnection As SqlConnection = New ...
    (microsoft.public.dotnet.general)
  • Re: Hi! Newbie Here
    ... >>This is my first post to the group, although I've been lurking for the ... >Good luck. ... >>I hope to control my BG with diet, excercise and the medicine. ... Wendy, ...
    (alt.support.diabetes)
  • Re: Check Out This Chem Supplier I Found
    ... sound like you 'found' it out of the blue - oh, ... Best of luck to you, ... inflated prices is one thing. ... Wasn't it obvious from the first post? ...
    (rec.pyrotechnics)
  • 1998 Suzuki Sidekick
    ... This is my first post here, I have googled for 3 hours with no luck and ... heater fan blower continues to run, the defroster will stay on, power ... The only reminder is if the fan is turned up high, so that it is loud, ...
    (rec.autos.tech)