only one radiobutton selection in repeater(中继器中只有一个单选按钮选择)
问题描述
我只想选择一个单选按钮,但我不能这样做.这是我的代码:
I want to select only one radio button but I cant do this. Here is my code:
<asp:Repeater ID="Repeater_secenekler" runat="server" DataSource='<%#Eval("Secenekler")%>'>
<HeaderTemplate>
<table>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="margin-left: 20px;">
<asp:CheckBox ID="CheckBox" runat="server" Text='<%#Eval("OptionName")%>' Visible='<%# Eval("TypeId").ToString() == "1" %>' />
<asp:RadioButton ID="RadioButton" runat="server" Text='<%#Eval("OptionName")%>' Visible='<%# Eval("TypeId").ToString() == "2" %>'
GroupName="RadioButtonGrup" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
我可以选择所有具有相同组名的单选按钮,但我不想要这个.我只想要一个选项.
I can select all radio button with same groupname but I dont want this. I want only one selection.
我该怎么做.谢谢.
推荐答案
这是使用 RadioButtons 的 ASP.NET 中继器的一个众所周知的错误:
This is a well known bug with the ASP.NET Repeater using RadioButtons:
http://support.microsoft.com/default.aspx?scid=kb;zh-cn;Q316495
这里有一个修复:
http://www.ifinity.com.au/Blog/EntryId/87/Simple-fix-for-Radio-Button-controls-in-an-ASP-NET-Repeater-using-jQuery
jQuery("[name$='$optValue']").attr("name",jQuery("[name$='$optValue']").attr("name"));
jQuery("[name$='$optValue]").click(function (){
//set name for all to name of clicked
jQuery("[name$='$optValue]").attr("name", this.attr("name"));
});
这篇关于中继器中只有一个单选按钮选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:中继器中只有一个单选按钮选择


基础教程推荐
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01