aspx页面
<asp:Repeater ID="rptData" runat="server"> <ItemTemplate> <tr id="trRemark" <%# Container.ItemIndex%2==0?"class="even"":" class="odd"" %>> <td> <input type="radio" value='<%# Eval("id")%>' name="radio_Box" id="radio_Box" class="C_B" runat="server" onclick="selectSingleRadio(this,'radio_Box')" /> </td> <td>
js模块
function selectSingleRadio(rbtn, GroupName) { //alert(rbtn + "==" + GroupName); $("input[type=radio]").each(function (i) { if (this.name.substring(this.name.length - GroupName.length) == GroupName) { this.checked = false; } }) rbtn.checked = true; }
后台
//保存数据 protected void SaveBtn_Click(object sender, EventArgs e) { string economicId; foreach (RepeaterItem item in this.rptData.Items) //repeater的Id { HtmlInputRadioButton economic = (HtmlInputRadioButton)item.FindControl("radio_Box"); if (economic.Checked) { economicId = economic.Value.ToString(); } } }