这是datagrid加checkbox选择删除string conn=System.Configuration.ConfigurationSettings.AppSettings["connstr"];SqlConnection myconn = new SqlConnection(conn);myconn.Open();int tmpCount = this.dgList.Items.Count;for (int i = 0 ; i< tmpCount; i++){string tmpID = this.dgList.DataKeys[i].ToString();CheckBox delCheckbox =(CheckBox)this.dgList.Items[i].FindControl("deleteCheckbox");if (delCheckbox.Checked){string strSql = "delete from member where memberID = " + tmpID;SqlCommand cmd = new SqlCommand(strSql,myconn);cmd.ExecuteNonQuery();}}this.myDataBind();myconn.Close();}请问这个在断点调试的时候delCheckbox的值显示为<未定义的值>麻烦!!!
參考答案:在pagelode中加if(ispostback){}加了就不回送了,你不加的话他总是会先初始化