Results 1 to 3 of 3

Thread: getting value of dropdownlist

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    30

    getting value of dropdownlist

    I currently loop through my drop down lists as per the below code. However, I would like to now get the vale out of each control but am struggling on how to do this? any ideas much appreciated.

    myValue as String
    Dim c As Control

    For Each c In Form1.Controls
    If TypeOf c Is DropDownList Then

    myValue = c.SelectedItem.Value 'does not work

    End If
    Next

  2. #2
    Member
    Join Date
    Sep 2005
    Posts
    50

    Re: getting value of dropdownlist

    There is a SelectedValue Property of the DropDownList Control that returns the selected valuevalue.

    So u should have c.SelectedValue

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2005
    Posts
    30

    Re: getting value of dropdownlist

    cheers but ended up having to use:

    myValue = DirectCast(c, DropDownList).SelectedItem.Value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width