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. how to get the dynamically created radiobutton checked values

how to get the dynamically created radiobutton checked values

Scheduled Pinned Locked Moved ASP.NET
tutorialquestion
6 Posts 3 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.
  • M Offline
    M Offline
    MalarGayu
    wrote on last edited by
    #1

    hi friends i am created radiobuttons dynamically and i am putting it in a list : say: List lstRadioButton; i am adding the radiobuttons id to the list and i am also adding the radio button text and checked value to the list and on the viewstate(i know that the buttons will not be there) so i am recreating it with the same id which i got from the list but dont know how to assign the text and checked value if am doing all these in order to get which of the radio buttons is checked... hope u got my question. K.Gayathri

    N 1 Reply Last reply
    0
    • M MalarGayu

      hi friends i am created radiobuttons dynamically and i am putting it in a list : say: List lstRadioButton; i am adding the radiobuttons id to the list and i am also adding the radio button text and checked value to the list and on the viewstate(i know that the buttons will not be there) so i am recreating it with the same id which i got from the list but dont know how to assign the text and checked value if am doing all these in order to get which of the radio buttons is checked... hope u got my question. K.Gayathri

      N Offline
      N Offline
      Nitish Arora Web Developer Learner
      wrote on last edited by
      #2

      Hi Gayathri, In order to get the radiobutton checked state you have to call some event handler on which you might do the coding like this : Button1_Click(Object sender,EventArgs e) { RadioButton rd=(RadioButton)sender; string id=rd.id; // It will provide you the Id of RadioButton clicked dynamically. } If you are having any other problem, Please post the whole code or mail the code to me on my e-mail id nitisharora007@gmail.com

      thanks & regards Nitish Arora Web Developer(Learner)

      M 1 Reply Last reply
      0
      • N Nitish Arora Web Developer Learner

        Hi Gayathri, In order to get the radiobutton checked state you have to call some event handler on which you might do the coding like this : Button1_Click(Object sender,EventArgs e) { RadioButton rd=(RadioButton)sender; string id=rd.id; // It will provide you the Id of RadioButton clicked dynamically. } If you are having any other problem, Please post the whole code or mail the code to me on my e-mail id nitisharora007@gmail.com

        thanks & regards Nitish Arora Web Developer(Learner)

        M Offline
        M Offline
        MalarGayu
        wrote on last edited by
        #3

        hi thanks for the reply but if i click the button i am not able to get the value(i mean the checked radiobuttons id) but on post back it says that the radiobuttons do not exist so i have recreated them on every post back but could not make the radiobuttons checked value to be set instead i am able to get only the id. plz do help me... stuck with this and not able to proceed further... K.Gayathri

        M 1 Reply Last reply
        0
        • M MalarGayu

          hi thanks for the reply but if i click the button i am not able to get the value(i mean the checked radiobuttons id) but on post back it says that the radiobuttons do not exist so i have recreated them on every post back but could not make the radiobuttons checked value to be set instead i am able to get only the id. plz do help me... stuck with this and not able to proceed further... K.Gayathri

          M Offline
          M Offline
          MalarGayu
          wrote on last edited by
          #4

          hi friends can anyone help me with this issue plz: i am creating dynamic radio buttons based on the values i choose from a dropdownlist and if i click the save button i am not able to get the radiobuttons clicked ids so how to do it..... looking for help.... K.Gayathri

          M 1 Reply Last reply
          0
          • M MalarGayu

            hi friends can anyone help me with this issue plz: i am creating dynamic radio buttons based on the values i choose from a dropdownlist and if i click the save button i am not able to get the radiobuttons clicked ids so how to do it..... looking for help.... K.Gayathri

            M Offline
            M Offline
            MalarGayu
            wrote on last edited by
            #5

            i am using the following code RadioButton rdl ; rdl = (RadioButton)PHEmailfmt.FindControl("rd1") as RadioButton; if (rdl != null) { if (rdl.Checked) { Response.Write("rd1 is checked"); } } rdl = (RadioButton)PHEmailfmt.FindControl("rd2") as RadioButton; if (rdl != null) { if (rdl.Checked) { Response.Write("rd2 is checked"); } } rdl = (RadioButton)PHEmailfmt.FindControl("rd3") as RadioButton; if (rdl != null) { if (rdl.Checked) { Response.Write("rd3 is checked"); } } } but the find control returns null so can anyone help me plz... i have created 3 dynamic radio buttons as rd1,rd2,rd3 and on the click of the save button i have the following.. K.Gayathri

            I 1 Reply Last reply
            0
            • M MalarGayu

              i am using the following code RadioButton rdl ; rdl = (RadioButton)PHEmailfmt.FindControl("rd1") as RadioButton; if (rdl != null) { if (rdl.Checked) { Response.Write("rd1 is checked"); } } rdl = (RadioButton)PHEmailfmt.FindControl("rd2") as RadioButton; if (rdl != null) { if (rdl.Checked) { Response.Write("rd2 is checked"); } } rdl = (RadioButton)PHEmailfmt.FindControl("rd3") as RadioButton; if (rdl != null) { if (rdl.Checked) { Response.Write("rd3 is checked"); } } } but the find control returns null so can anyone help me plz... i have created 3 dynamic radio buttons as rd1,rd2,rd3 and on the click of the save button i have the following.. K.Gayathri

              I Offline
              I Offline
              Ibrahim Hebish
              wrote on last edited by
              #6

              at first, i don't know why you don't use an

              it will give you what you want exactly with less effort if it is: it would be like that:

              you can create items in it dynamically like this:

              ListItem item = new ListItem("Text");
              _radioButtonList.Items.Add(item);

              and to get SelectedItem , its Text or Value just do like that:

              ListItem item=_radioButtonList.SelectedItem;
              string selectedItemText=_radioButtonList.SelectedItem.Text;
              string selectedItemValue=_radioButtonList.SelectedValue;

              you can take SelectedValue in the Save Button Click

              Sincerely, Ibrahim Hebish | SharePoint Software Developer |GlobeSoft(Comp)| EX:EgyptNetwork(Comp) M: +201281744594 Email: Pronto.cs@gmail.com

              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