我的頁面上有一個radiobuttonlist(裏面有8個子項)和兩個radiobutton,要怎麼實現單選啊。。
請大家幫忙看下
最笨的方法
將兩個radiobutton分別放在兩個Panel裏,這樣能區分看每個單選,可以判斷你選了那個
或者爲他們設置ValidationGroup屬性,設置爲不同的組別
每個控件都有一個ID你選了那個,就能判斷出來,如果需要實現整個頁面只可以選一個,那就判斷一個選中後把另外的Enable
<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
RadioButton1.GroupName = RadioButtonList1.UniqueID;
RadioButton2.GroupName = RadioButtonList1.UniqueID;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<asp:RadioButton ID="RadioButton2" runat="server" Text="RadioButton2" />
<asp:RadioButton ID="RadioButton1" runat="server" Text="RadioButton1" />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>ddd</asp:ListItem>
<asp:ListItem>ddd</asp:ListItem>
<asp:ListItem>ddd</asp:ListItem>
<asp:ListItem>ddd</asp:ListItem>
</asp:RadioButtonList>
</form>
</body>
</html>
來源:英超直播