当我使用以下代码以编程方式创建单选按钮列表时
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RadioButtonList.Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<% for (int i = 0; i < 2; i++)
{
anketsonucu.ID = i.ToString();
%>
<div>
<br />
<label>
<span class="questionicon">>></span> Deneme</label>
<asp:RadioButtonList ID="anketsonucu" runat="server" RepeatDirection="Horizontal"
CssClass="anketsonucu">
<asp:ListItem Text="Çok Kötü" Value="1"></asp:ListItem>
<asp:ListItem Text="Kötü" Value="2"></asp:ListItem>
<asp:ListItem Text="Orta" Value="3"></asp:ListItem>
<asp:ListItem Text="İyi" Value="4"></asp:ListItem>
<asp:ListItem Text="Çok İyi" Value="5"></asp:ListItem>
</asp:RadioButtonList>
</div>
<%
}
%>
</div>
</form>
</body>
</html>
它给了我这个页面源
<div>
<br />
<label>
<span class="questionicon">>></span> Deneme</label>
<table id="0" class="anketsonucu">
<tr>
<td><input id="0_0" type="radio" name="0" value="1" />
<label for="0_0">Çok Kötü</label></td><td><input id="0_1" type="radio" name="0" value="2" />
<label for="0_1">Kötü</label></td><td><input id="0_2" type="radio" name="0" value="3" />
<label for="0_2">Orta</label></td><td><input id="0_3" type="radio" name="0" value="4" />
<label for="0_3">İyi</label></td><td><input id="0_4" type="radio" name="0" value="5" />
<label for="0_4">Çok İyi</label></td>
</tr>
</table>
</div>
<div>
<br />
<label>
<span class="questionicon">>></span> Deneme</label>
<table id="1" class="anketsonucu">
<tr>
<td><input id="1_0" type="radio" name="0" value="1" /><label for="1_0">Çok Kötü</label></td><td>
<input id="1_1" type="radio" name="0" value="2" /><label for="1_1">Kötü</label></td><td>
<input id="1_2" type="radio" name="0" value="3" /><label for="1_2">Orta</label></td><td>
<input id="1_3" type="radio" name="0" value="4" /><label for="1_3">İyi</label></td><td>
<input id="1_4" type="radio" name="0" value="5" /><label for="1_4">Çok İyi</label></td>
</tr>
</table>
</div>
</div>
如果你仔细看,所有控件的“名称”属性都为零,所以我不能为不同的两个单选按钮列表选择两个选项。我只能选择一个。
如何更改单选按钮的名称属性,以便我可以同时为不同的单选按钮列表选择两个单选按钮?