protected void btnSave_Click(object sender, System.EventArgs e) { try { System.Collections.Generic.List <ResType> list = new System.Collections.Generic.List <ResType>(); foreach (GridViewRow gridViewRow in this.gvwResType.Rows) { string id = this.gvwResType.DataKeys[gridViewRow.RowIndex].Value.ToString(); ResType byId = ResType.GetById(id); DropDownList dropDownList = (DropDownList)gridViewRow.FindControl("ddlCBS"); if (!string.IsNullOrEmpty(dropDownList.SelectedValue.Trim())) { byId.CBSCode = dropDownList.SelectedValue.Trim(); } else { byId.CBSCode = null; } list.Add(byId); } ResType.Update(list); base.RegisterScript("alert('系统提示:\\n修改成功!');"); } catch { base.RegisterScript("alert('系统提示:\\n修改失败!');"); } }