在服务器端动态生成的name总是不断变化,故需手动实现单选 ;
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function SinggleSelect(ob) {
$("#<%=dglist.ClientID %>").find("input[type='radio']").each(function () {
$(this).attr("checked", false);
});
$(ob).attr("checked", true);
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="dglist" runat="server" >
<Columns>
<asp:BoundField DataField="Name" HeaderText="名字" />
<asp:BoundField DataField="Age" HeaderText="年龄" />
<asp:BoundField DataField="Sex" HeaderText="性别" />
<asp:TemplateField HeaderText="选择">
<ItemTemplate>
<asp:RadioButton ID="rbSelect" onclick="SinggleSelect(this)" runat="server" />
</Itemtemplate>
</asp:TemplateField>
</Columns> </asp:GridView>
</div>
</form>
</body>
</html>