本文介绍了单选按钮的设置值属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建的单选按钮,基于数据的列表,我从我的数据库返回。每个按钮都需要有与它相关联,基于所选择的按钮我可以走出一个值

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.

另一种方法是创建单独的单选和包装他们一个面板中的分组。然而,似乎没有要在一个Value属性单选

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.

目前,我想我可能不得不求助于使用HTML单选按钮与 =服务器,必须有一个更好的办法...?

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

推荐答案

您可以创建一个扩展的标准之一,并增加了一个value属性自己的单选按钮类:

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; }
}

这篇关于单选按钮的设置值属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 16:56