How to disable one radio button in the RadioButtonList1 (asp.net)

E

enahar

I have created RadioButtonList1 having 2 radio buttons in the list.How to
make enable/disable only 1 radio button in the RadioButtonlist.

Thanks for your help.


Regards.
 
D

ddd

I am using the below control
protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;

It doesnot have enabled property.Thanks
 
E

enahar

I am using the below control
protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;

It doesnot have enabled property.

Thanks
 
G

Guest

I would replace the RadioButtonList with individual RadioButtons that are
wired to the same event handling method, e.g.

<asp:RadioButton AutoPostBack=True ID="Radiobutton1" Runat="server"
Text="value1" OnCheckedChanged
="Radiobutton_CheckedChanged"></asp:RadioButton>
<asp:RadioButton AutoPostBack=True ID="Radiobutton2" Runat="server"
Text="value2" OnCheckedChanged
="Radiobutton_CheckedChanged"></asp:RadioButton>


And in the codebehind:

protected void Radiobutton_CheckedChanged(object sender, System.EventArgs e)
{
//uncheck all radio buttons
Radiobutton1.Checked = false;
Radiobutton2.Checked = false;
//check the button that was clicked
RadioButton rb = (RadioButton)sender;
rb.Checked = true;
//do any other processing

}
 
Joined
Oct 7, 2006
Messages
1
Reaction score
0
You need to use a trick here to solve this problem:

Let's say if you want to display second radio button (index 1) in the radioButtonList, myRadioButtonList:

myRadioButtonList.SelectedIndex = 1;
myRadioButtonList.SelectedItem.Enabled = false;

Regards,
Learner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top