protected void gvMajor_RowUpdating(object sender, GridViewUpdateEventArgs e) { int id = Convert.ToInt32(gvMajor.DataKeys[e.RowIndex].Value.ToString()); string name = ((TextBox)(gvMajor.Rows[e.RowIndex].Cells[2].Controls[0])).Text; Fannie.InitSystem init = new Fannie.InitSystem(); if (init.ModifyMajor(id, name) > 0) { gvMajor.EditIndex = -1; GetMajor(); Response.Write("<script>alert('修改成功')</script>"); } }
protected void btnUpdate_Click(object sender, EventArgs e) { Fannie.InitSystem init = new Fannie.InitSystem(); int id; string name; for (int i = 0; i < gvMajor.Rows.Count; i++) { if (((CheckBox)(gvMajor.Rows[i].Cells[0].Controls[0])).Checked) { id = Convert.ToInt32(gvMajor.DataKeys[i].Value.ToString()); name = ((TextBox)gvMajor.Rows[i].FindControl("tbMajor")).Text; init.ModifyMajor(id, name); } } GetMajor(); btnDelete.Enabled = true; btnNew.Enabled = true; }