本文介绍了如何选择一个radiobutton?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有以下代码将信息显示在gridview中并允许用户选择,但我希望用户只选择一个选项而不是多个选项。 < 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 GroupName = 选择 / > < / ItemTemplate > < / 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 09-02 18:01