> -----Original Message-----
> From: Wayne Lee [mailto:[EMAIL PROTECTED]]
>
> Yeah but how do I find out the index? When I loop through I
> am checking the value property of the dropdown against the
> session value. When a match is found how do I get the index?

Ahh..
This is what I use: (VB.NET)

    Private Overloads Sub selectByValue(ByVal dropdown As DropDownList, _
                                                ByVal value As String)
        Dim index As Integer
        Dim maxIndex As Integer = dropdown.Items.Count

        Do Until index = maxIndex _
                        OrElse dropdown.Items(index).Value = value
            index += 1
        Loop
        If index = maxIndex Then
            'value not found, so select the first one
            dropdown.SelectedIndex = 0
        Else
            dropdown.SelectedIndex = index
        End If
    End Sub

(it's overloaded to accept integer,date,etc values..similar code, but some
casting the value to a string is involved in the other functions)

Merak

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to