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