protected void btnDeleteChild_Click(object sender, EventArgs e) { int[] intRowindexarray = childGrid.SelectedRowIndexArray; if (intRowindexarray.Length > 0) { bi_heatdevice_repair bhdr = new bi_heatdevice_repair(); object[] keys = childGrid.DataKeys[intRowindexarray[0]]; string strID = null; if (keys[0] != null) { strID = keys[0].ToString(); } string strhdid = null; if (keys[1] != null) { strhdid = keys[1].ToString(); } //string strID = keys[0].ToString(); //string strhdid = keys[1].ToString();出现了key[]=null的异常 Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("ID", " cast(ID as varchar(36))='" + strID + "' "); int intresult = 0; intresult = bhdr.deletebycondition("bi_heatdevice_repair", dic); strhdid = editID.Text.ToString().Trim(); BindchildGrid(strhdid); Alert alert = new Alert(); if (intresult > 0) { alert.Icon = Icon.Information; alert.Message = "成功移除数据"; } else { alert.MessageBoxIcon = MessageBoxIcon.Error; alert.Message = "数据移除失败"; } alert.Show(); } }