Set value property of RadioButton Set value property of RadioButton asp.net asp.net

Set value property of RadioButton


You could create your own radio button class which extends the standard one and adds a value property:

public class ValueCheckBox : System.Web.UI.WebControls.RadioButton{    public string Value { get; set; }}


You can always try using attributes to save the associated value.eg)

radioButton.Attributes.Add("Key", "Value");

Set the Group property to be the same for all the radio buttons and you should be good to go. Just remember, ASP .Net has a slight problem if these individual radio buttons are in different rows of a repeater, gridview or some such grid-style.


For a quick and dirty set of STATIC radio buttons.
I used the Tag field in the Properties window to manually define a value.

If you are using a DB you should probably bind your data to it. You never know when you'll change a key or name.