Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set value property of RadioButton

I need to built a list of radio buttons, based on data I return from my DB. Each button needs to have a value associated with it that I can get out based on the selected button.

Ideally I would just use the RadioButtonList control, however, I need to have a very custom layout which a RadioButtonList doesn't appear to be able to handle.

An alternative would be to create individual RadioButtons and wrap them in a Panel to group them. However, there doesn't appear to be a Value property on a RadioButton?

Is there an alternative way to set a value to a RadioButton control? Alternatively, a way to completely customise the RadioButtonList output.

At the moment, I'm thinking I might have to resort to using HTML radio buttons with runat="server", must be a better way...?

like image 745
Dan Ellis Avatar asked Feb 20 '12 21:02

Dan Ellis


People also ask

What is the value property of a radio button?

Definition and Usage. The value property sets or returns the value of the value attribute of the radio button. For radio buttons, the contents of the value property do not appear in the user interface. The value property only has meaning when submitting a form. If a radio button is in checked state when the form is submitted,...

How do I set the radio button values?

Select a property, the value of which will be set by the radio button selected at run time. You can configure a list of options for the radio buttons in the List Source area, as well as select the caption and value for the radio button options.

What is a radiobutton?

The .NET MAUI RadioButton is a type of button that allows users to select one option from a set. Each option is represented by one radio button, and you can only select one radio button in a group. RadioButton - .NET MAUI | Microsoft Docs Skip to main content This browser is no longer supported.

What is radio button in VB NET?

VB.Net - RadioButton Control. The RadioButton control is used to provide a set of mutually exclusive options. The user can select one radio button in a group.


1 Answers

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; }
}
like image 179
Trevor Pilley Avatar answered Sep 19 '22 13:09

Trevor Pilley