你的位置:首页 > ASP.net教程

[ASP.net教程]asp.net中gridview嵌套radiobutton时,选中时默认全是false,求解。。。


<script type="text/javascript">
//控制单选的js
function setRadio() {
      var dom = document.all;
      var ele = event.srcElement;
      if (ele.tagName == "INPUT" && ele.type.toLowerCase() == "radio") {
      for (i = 0; i < dom.length; i++) {
      if (dom[i].tagName == "INPUT" && dom[i].type.toLowerCase() == "radio") {
      dom[i].checked = false;
     }
  }
}
  ele.checked = true;
}
</script>

//这里checked全为false

protected void btnOK_Click1(object sender, EventArgs e)
{
for (int i = 0; i < this.People.Rows.Count; i++)
{
RadioButton SingleSelectd = this.People.Rows[i].Cells[0].FindControl("SingleSelect") as RadioButton;

if (SingleSelectd.Checked == true)
{
sID = this.People.Rows[i].Cells[1].Text;
}
}
}