我有一个gridview,我在其中以编程方式添加了复选框。在 foreach 循环中创建复选框时,我会执行以下操作,以便它们在选中时触发事件,
cbGV = new CheckBox();
cbGV.ID = "cbGV";
cbGV.AutoPostBack = true;
cbGV.CheckedChanged += new EventHandler(this.cbGV_CheckedChanged);
所以基本上当我想要触发事件时,我有以下内容,
protected void cbGV_CheckedChanged(object sender, EventArgs e)
{
//gets the current checked checkbox.
CheckBox activeCheckBox = sender as CheckBox;
foreach (GridViewRow gvr in GridView1.Rows)
{
//this code is for finding the checkboxes in the gridview.
CheckBox checkBox = ((CheckBox)gvr.FindControl("cbGV"));
//so basically, right here i'm confused on how i should compare the if/else logic, how i should compare and disable every other checkbox if the current checkbox is checked. Any ideas gues?
}
提前感谢您的回答。