I am trying to get the seleted radioButton from a group of radio buttons.
The program is supposed to check on the database for controls that match the selected radiobuttons. The radiobuttons are named High,Medium,Low.
If a person selects High, the program must go through the database and choose all the controls that are rated High and then must load them into a listBox.
My problem is that the code i am using does not see the selected items and does not load the listBox.
I am usig SQL server database and stored procedures to do this.
Any suggestions on how i can go about doing this will be appreciated.
EDIT: re-read your post and realised you need to poulate the list when the radio is changed, revised code :)
Rather than checking each one for the check status, why not handle the controls check changed event to show list:
this.rdoHigh.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
this.rdoMedium.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
this.rdoLow.CheckedChanged += new System.EventHandler(this.radioButton_CheckedChanged);
//set the rdo Text to the desired value: High/Medium/Low
//then handle the check changed event to update list
private void radioButton_CheckedChanged(object sender, EventArgs e)
string selected = String.Empty;
Selected = ((CheckBox)sender).Text;
//execute query and populate list
Ryshad: I don't agree with that approach, you should always go to the source to check for values. If not you leave an opportunity for the values to become desynched and it will load to a bug. It will probably work 99.9% of the time but that other 0.1 bothers me ;)
Twyce: Can you explain what you are trying to accomplish in more detail?