Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. setting DropDownList value

setting DropDownList value

Scheduled Pinned Locked Moved ASP.NET
questiondatabasehelp
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    liz3
    wrote on last edited by
    #1

    I have a table in a database with certain fields which the user fills up through a form.At a later point,if the user wishes to see this form,I need to auto-fill those fields.The auto-fill works except for the DropDownList control.It always sets its field to the first item in the datalist.I tried 'DropDownList2.Items.FindByText(string).selected="True"' but it shows an error. I need the dropdownlist to show the text that was previously selected by the user and also giving the user an option to change his previous selection. How do i do this?

    E 1 Reply Last reply
    0
    • L liz3

      I have a table in a database with certain fields which the user fills up through a form.At a later point,if the user wishes to see this form,I need to auto-fill those fields.The auto-fill works except for the DropDownList control.It always sets its field to the first item in the datalist.I tried 'DropDownList2.Items.FindByText(string).selected="True"' but it shows an error. I need the dropdownlist to show the text that was previously selected by the user and also giving the user an option to change his previous selection. How do i do this?

      E Offline
      E Offline
      Expert Coming
      wrote on last edited by
      #2

      DropDownList.Items.IndexOf(DropDownList.Items.FindByValue("InsertValueToFind")) That is one of the ways I do it.

      The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo

      L 1 Reply Last reply
      0
      • E Expert Coming

        DropDownList.Items.IndexOf(DropDownList.Items.FindByValue("InsertValueToFind")) That is one of the ways I do it.

        The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo

        L Offline
        L Offline
        liz3
        wrote on last edited by
        #3

        [Message Deleted]

        E 2 Replies Last reply
        0
        • L liz3

          [Message Deleted]

          E Offline
          E Offline
          Expert Coming
          wrote on last edited by
          #4

          Do you set the value of the DropDownList, or just the text?

          The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo

          1 Reply Last reply
          0
          • L liz3

            [Message Deleted]

            E Offline
            E Offline
            Expert Coming
            wrote on last edited by
            #5

            Try the FindByText one.

            The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups