首页 .NET/Web 多个RadioButtonList组 动态读取只能选择唯一一个的解决方案

多个RadioButtonList组 动态读取只能选择唯一一个的解决方案

作者:胡同里的砖头 围观群众:856 更新于:2013-12-19

                <asp:Panel ID="Panel1" runat="server" GroupingText="未脱轨" Width="100%" HorizontalAlign="Left">
                    <asp:RadioButtonList ID="RadioButtonList1" runat="server" 
                        DataTextField="title" DataValueField="Id"
                        onselectedindexchanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true">
                    </asp:RadioButtonList>
                </asp:Panel>
                <asp:Panel ID="Panel2" runat="server" GroupingText="未脱轨" Width="100%" HorizontalAlign="Left">
                    <asp:RadioButtonList ID="RadioButtonList2" runat="server" DataTextField="title"
                        DataValueField="Id" ValidationGroup="a"
                        onselectedindexchanged="RadioButtonList2_SelectedIndexChanged" AutoPostBack="true">
                    </asp:RadioButtonList>
                </asp:Panel>

后台:

protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        RadioButtonList2.ClearSelection();
    }
    protected void RadioButtonList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        RadioButtonList1.ClearSelection();
    }

设置autopostback为true,当有选中触发的时候,就回传清空其它组里面的选中项

  • 本文标题: 多个RadioButtonList组 动态读取只能选择唯一一个的解决方案
  • 文章分类:【.NET/Web】
  • 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
留言评论
站点声明:
1、本站【胡同里的砖头】个人博客,借鉴网上一些博客模板,取其各优点模块自行拼装开发,本博客开发纯属个人爱好。
2、所有笔记提供给广大用户交流使用,可转载,可复制,纯个人开发所遇问题锦集记录使用
Copyright © huzlblog.com All Rights Reserved. 备案号:苏ICP备2021056683号-8