如何选择一个radiobutton? [英] How to make radiobutton selected one at time?

查看:100
本文介绍了如何选择一个radiobutton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码将信息显示在gridview中并允许用户选择,但我希望用户只选择一个选项而不是多个选项。



< pre lang =HTML> < asp:GridView ID = grid runat = server AutoGenerateColumns = False DataSourceID = SqlDataSource1 d ataKeyNames = ID >
< >
< asp:BoundField DataField = ID HeaderText = ID SortExpression = ID / >
< asp:BoundField DataField = 标题 HeaderText = 标题 SortExpression = 标题 / >
< asp:TemplateField HeaderText = 选择 >
< ItemTemplate >
< asp:RadioButton ID = CheckBox1 runat = server < span class =code-attribute> GroupName = 选择 / >
< / ItemTemplate >
< < span class =code-leadattribute> / asp:TemplateField >
< /列 >





那么如何让用户只检查一个RadioButton?

解决方案

我建​​议使用RadioButtonList控件而不是GridView, http://asp-net-example.blogspot.com/2008/10/radiobuttonlist-example-how-to-use.html [ ^ ]



网上有很多样品,但上面的链接很好。


I have the below code to display information into gridview and enable user to select choice, but I want user to select only one choice not multiple choices.

<asp:GridView ID="grid" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="ID">
<Columns>
   <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" />
   <asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
   <asp:TemplateField HeaderText="Select">
       <ItemTemplate>
           <asp:RadioButton ID="CheckBox1" runat="server" GroupName="select"/>
       </ItemTemplate>
   </asp:TemplateField>
</Columns>



So how can I allow user to check only one RadioButton?

解决方案

I would suggest using a RadioButtonList control instead of a GridView, http://asp-net-example.blogspot.com/2008/10/radiobuttonlist-example-how-to-use.html[^]

There are lots of samples online but the above link is a good one.


这篇关于如何选择一个radiobutton?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆