FindByText in dropdownlist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aneri
    New Member
    • Feb 2007
    • 11

    FindByText in dropdownlist

    How to use FindByText property of dropdownlist where text to find is in a textbox? i.e

    if i write,
    dropdownlist1.I tems.FindByText (" ' "& txt1.Text &" ' ").Selected = True

    i get error
    System.NullRefe renceException: Object reference not set to an instance of an object
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Try putting txt1.text into a string, eg myString, writing it to ensure it has a value and then use:
    Code:
    dropdownlist1.Items.FindByText(myString).Selected = True

    Comment

    • Aneri
      New Member
      • Feb 2007
      • 11

      #3
      Originally posted by kenobewan
      Try putting txt1.text into a string, eg myString, writing it to ensure it has a value and then use:
      Code:
      dropdownlist1.Items.FindByText(myString).Selected = True




      It's not working.Getting the same error.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Write myString...

        Comment

        • Aneri
          New Member
          • Feb 2007
          • 11

          #5
          Originally posted by kenobewan
          Write myString...

          I tried by writing:

          dim myString as string
          myString = txt1.Text
          dropdownlist1.F indByText(myStr ing).Selected = True

          But Getting the same error.

          Comment

          Working...