我目前在单选按钮和分组方面有问题.我在中继器控件中有一个asp单选按钮.我将"组名"属性设置为"客户".加载页面时,单选按钮不分组.它不是将id字段设置为组名,而是设置单选按钮的值字段.我知道我曾try 在中继器控制之外设置单选按钮,但也遇到了同样的问题.这是怎么回事?

aspx

<asp:Repeater ID="repCustomers" runat="server">
    <HeaderTemplate>
        <table class="tableDefault" cellpadding="0" cellspacing="0" border="0" style="width: 383px; border: 0px !important">
            <tr>
                <th>&nbsp;</th>
                <th>Cust. No.</th>
                <th>Cust. Name</th>
            </tr>
    </HeaderTemplate>
    <ItemTemplate>
            <tr>
                <td>
                    <asp:RadioButton ID="radCustomer" GroupName="Customer" runat="server" ValidationGroup="Customer" ToolTip='<%#Eval("CustomerNumber") %>' />
                </td>
                <td><%#Eval("CustomerNumber")%></td>
                <td><%#Eval("Name") %></td>
            </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
</asp:Repeater>

output html

<table class="tableDefault" cellpadding="0" cellspacing="0" border="0" style="width: 383px; border: 0px !important">
    <tr>
        <th>&nbsp;</th>
        <th>Cust. No.</th>
        <th>Cust. Name</th>
    </tr>

    <tr>
        <td>
            <span title="111111"><input id="ctl00_PrimaryContent_repCustomers_ctl01_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl01$Customer" value="radCustomer" /></span>
        </td>
        <td>111111</td>
        <td>Jeremy's Test</td>
    </tr>

    <tr>
        <td>
            <span title="222222"><input id="ctl00_PrimaryContent_repCustomers_ctl02_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl02$Customer" value="radCustomer" /></span>
        </td>
        <td>222222</td>
        <td>My Test</td>
    </tr>

    <tr>
        <td>
            <span title="333333"><input id="ctl00_PrimaryContent_repCustomers_ctl03_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl03$Customer" value="radCustomer" /></span>
        </td>
        <td>333333</td>
        <td>Jim Bob's BBQ</td>
    </tr>

    <tr>
        <td>
            <span title="444444"><input id="ctl00_PrimaryContent_repCustomers_ctl04_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl04$Customer" value="radCustomer" /></span>
        </td>
        <td>444444</td>
        <td>New Hope Hamburgers</td>
    </tr>

    <tr>
        <td>
            <span title="555555"><input id="ctl00_PrimaryContent_repCustomers_ctl05_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl05$Customer" value="radCustomer" /></span>
        </td>
        <td>555555</td>
        <td>Pied Piper Pizza</td>
    </tr>

    <tr>
        <td>
            <span title="666666"><input id="ctl00_PrimaryContent_repCustomers_ctl06_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl06$Customer" value="radCustomer" /></span>
        </td>
        <td>666666</td>
        <td>Sandy's Subs</td>
    </tr>

    <tr>
        <td>
            <span title="777777"><input id="ctl00_PrimaryContent_repCustomers_ctl07_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl07$Customer" value="radCustomer" /></span>
        </td>
        <td>777777</td>
        <td>Leonard's Lambchops</td>
    </tr>

    <tr>
        <td>
            <span title="888888"><input id="ctl00_PrimaryContent_repCustomers_ctl08_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl08$Customer" value="radCustomer" /></span>
        </td>
        <td>888888</td>
        <td>Dave's Diamond Deli</td>
    </tr>

    <tr>
        <td>
            <span title="999999"><input id="ctl00_PrimaryContent_repCustomers_ctl09_radCustomer" type="radio" name="ctl00$PrimaryContent$repCustomers$ctl09$Customer" value="radCustomer" /></span>
        </td>
        <td>999999</td>
        <td>Ernie's Eatery</td>
    </tr>

</table>

推荐答案

我最终通过创建一个简单的单选按钮并使用服务器端eval设置值来解决这个问题.

<input type="radio" name="radCustomer" value='<%#Eval("CustomerNumber") %>' />

现在,当应用程序执行回发时,我判断Request的值.表格["radCustomer"].这是完美的.

Asp.net相关问答推荐

jQuery隐藏字段

任何人都有解决 Internet Explorer 上剩余 n 项问题的 idea 吗?

Azure Service Fabric 是否与 Docker 做同样的事情?

带有 Web 套接字的 SignalR

如何使用 SmtpClient.SendAsync 发送带有附件的邮箱?

无法访问,内部,资源文件?

UseSqlServer 方法缺少 MVC 6

显示单选按钮列表内联

排序下拉列表? - C#,ASP.NET

Ef core:执行 MaxAsync 时序列不包含任何元素

IIS 10 上的 ASP.NET Core 404 错误

带有 ASP.NET WebMethod 的 Jquery AJAX 返回整个页面

显示 ModalPopupExtender 时如何指定要运行的 javascript

如何在 ASP.Net Gridview 中添加确认删除选项?

不同域的登录页面

ASP.NET 按钮重定向到另一个页面

在 ASP.NET MVC 中模拟 User.Identity

ASP.Net 哪个用户帐户在 IIS 7 上运行 Web 服务?

IE9 JavaScript 错误:SCRIPT5007:无法获取属性ui的值:对象为空或未定义

无法使用 ip:port 访问 WEB API,但可以在 VS 调试模式下使用 localhost:port