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"));
});
这篇关于中继器中只有一个单选按钮选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:中继器中只有一个单选按钮选择


基础教程推荐
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- c# Math.Sqrt 实现 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01