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. Dropdownlist box and Radio Button Display

Dropdownlist box and Radio Button Display

Scheduled Pinned Locked Moved ASP.NET
databasehelp
6 Posts 5 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.
  • R Offline
    R Offline
    Rajiya
    wrote on last edited by
    #1

    hi I have a dropdownlist box which stores the gender i.e. Male and Female. When i submit the form, depending on the value selected from the dropdownlist , the value get stored in the database as male or Female.Now when i try to edit that patricular record then it always displays the first entry.Same things happens with the radio button...by default it displays the first radio button as selected on the display. Waiting for help... Riz

    P S M 3 Replies Last reply
    0
    • R Rajiya

      hi I have a dropdownlist box which stores the gender i.e. Male and Female. When i submit the form, depending on the value selected from the dropdownlist , the value get stored in the database as male or Female.Now when i try to edit that patricular record then it always displays the first entry.Same things happens with the radio button...by default it displays the first radio button as selected on the display. Waiting for help... Riz

      P Offline
      P Offline
      Prasad Babu A
      wrote on last edited by
      #2

      Hi, U can code like this. ddl.SelectedItem.Text = "three"; or ddl.Items.FindByText("Three").Selected = true; I hope this will helps u. Bye Pessi.

      1 Reply Last reply
      0
      • R Rajiya

        hi I have a dropdownlist box which stores the gender i.e. Male and Female. When i submit the form, depending on the value selected from the dropdownlist , the value get stored in the database as male or Female.Now when i try to edit that patricular record then it always displays the first entry.Same things happens with the radio button...by default it displays the first radio button as selected on the display. Waiting for help... Riz

        S Offline
        S Offline
        Slow Learner
        wrote on last edited by
        #3

        Rajiya, Correct me if I am my understanding is right. You are storing the dropdowlist box value and the radio button value in the database. But you when you retrieve these values from the database to edit you always see the default selection of your .aspx page. Is this right? If so, my guess would be either the program is not saving the values to datbase properly or may be the values aren't being retrieved and handled properly inorder for them to display in your display.aspx page. I would check the database values and the code snippet that is posting the values to the front. Thanks -L

        R 2 Replies Last reply
        0
        • S Slow Learner

          Rajiya, Correct me if I am my understanding is right. You are storing the dropdowlist box value and the radio button value in the database. But you when you retrieve these values from the database to edit you always see the default selection of your .aspx page. Is this right? If so, my guess would be either the program is not saving the values to datbase properly or may be the values aren't being retrieved and handled properly inorder for them to display in your display.aspx page. I would check the database values and the code snippet that is posting the values to the front. Thanks -L

          R Offline
          R Offline
          rizmi
          wrote on last edited by
          #4

          hi, Depending upon what is selected from the dropdownlist, appropriate values get stored in the database.But when it is displaying the values then by default always the first value is displayed in the listbox and as well as in the radio button. If i have selected as "Female" from the dropdown list box then in the database it stores as "Female" but when i want to edit that particular record then it shows me as "Male" in the form.Am using ASP.Net and C# to do the coding. Riz

          1 Reply Last reply
          0
          • S Slow Learner

            Rajiya, Correct me if I am my understanding is right. You are storing the dropdowlist box value and the radio button value in the database. But you when you retrieve these values from the database to edit you always see the default selection of your .aspx page. Is this right? If so, my guess would be either the program is not saving the values to datbase properly or may be the values aren't being retrieved and handled properly inorder for them to display in your display.aspx page. I would check the database values and the code snippet that is posting the values to the front. Thanks -L

            R Offline
            R Offline
            rizmi
            wrote on last edited by
            #5

            In the database it saves the proper value but if i want to edit a value then on the display of the form it shows me the first value as selected from the dropdownlist box as well as Radio Button. For e.g. If I am having "Male" and "Female" in the ddlist and if i have selected "Female" then it will display "Male" by default even though it saves it as "Female" in the database.Am using ASP.Net and C# to do the coding. riz

            1 Reply Last reply
            0
            • R Rajiya

              hi I have a dropdownlist box which stores the gender i.e. Male and Female. When i submit the form, depending on the value selected from the dropdownlist , the value get stored in the database as male or Female.Now when i try to edit that patricular record then it always displays the first entry.Same things happens with the radio button...by default it displays the first radio button as selected on the display. Waiting for help... Riz

              M Offline
              M Offline
              Mircea Grelus
              wrote on last edited by
              #6

              Populate the dropdown list only if the page is not postbacked. private void Page_Load(object sender, System.EventArgs e) {    if(!Page.IsPostBack)     {     //code to populate dropdown     } } What you're doing right now is repopulating the dropdown list every time the page is postbacked. regards, Mircea Many people spend their life going to sleep when they’re not sleepy and waking up while they still are.

              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