|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to make to RadioButtonList on the same groupI have two RadioButtonList that binding two seperate lists. However, I
would like to make them in the same group, which means when one RadioButtonList has any selected item, the other RadioButtonList will have no selected item. Is there any way to do that easily? Thanks Hello John,
You want that when one RadioButtonList has any selected item, the other RadioButtonList will have no selected item. So, for this you can use this sample code. Hope this will help you. For this you have to set "AutoPostBack" property of Checkboxlist to "True". And then write the following code: protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { for (int i = 0; i < RadioButtonList1.Items.Count; i++) { if (RadioButtonList1.Items[i].Selected == true) { for (int j = 0; j < RadioButtonList2.Items.Count; j++) RadioButtonList2.Items[j].Selected = false; break; } } } Mansi Shah. *** Sent via Developersdex http://www.developersdex.com *** Mansi ,
That works. Thanks so much.! Show quote "Mansi Shah" <ma***@devdex.com> wrote in message news:OEQZ6gKEIHA.3980@TK2MSFTNGP03.phx.gbl... > Hello John, > > > You want that when one RadioButtonList has any selected item, the other > RadioButtonList will have > no selected item. > > So, for this you can use this sample code. Hope this will help you. > For this you have to set "AutoPostBack" property of Checkboxlist to > "True". > > And then write the following code: > > protected void RadioButtonList1_SelectedIndexChanged(object sender, > EventArgs e) > { > for (int i = 0; i < RadioButtonList1.Items.Count; i++) > { > if (RadioButtonList1.Items[i].Selected == true) > { > for (int j = 0; j < RadioButtonList2.Items.Count; j++) > RadioButtonList2.Items[j].Selected = false; > break; > } > } > } > > Mansi Shah. > > *** Sent via Developersdex http://www.developersdex.com *** |
|||||||||||||||||||||||