Hi, this sounds to me as if you are a little confused by what the various properties of the radio button control do and how to create the radio button correctly.
The ID property here is the key.
You must set a unique string for the ID property, which you then use to access the control in the postback.
GroupName is just an alias for the standard property of the switch name and is used when a user clicks on a switch in a group, only one radio book can be selected.
For example:
//add list to radio button list RadioButton radioButton = new RadioButton(); radioButton.GroupName = "radioGroup"; radioButton.Text = singleType.appTypeID.ToString(); radioButton.ID = singleType.appTypeName; radioArea.Controls.Add(radioButton); Label label = new Label(); label.Text = "<br />"; radioArea.Controls.Add(label);
In the above example, I assigned singleType.appTypeName as an identifier, considering it to be unique.
Then, to extract the value in postback, do this, assumnig that singleType.appTypeName = "mySuperApp":
RadioButton radioButton = (RadioButton) radioArea.FindControl("mySuperApp");
Now you can access the radioButton variable to check which one belongs to GroupName, get it and check that it is checked.
You will need to flip the switches to see which one is installed. An easy way to do this is to iterate over the radioArea child controls and check the eack control to see if it is a switch, and if it is installed. Other parameters are to provide each identifier with a prefix ie ID = "RAD _" + singleType.appTypeName and a loop over the Request object and match each of them with the correct suffix.
Tim saunders
source share