private void dg_update3(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { int ItemID = int.Parse(e.Item.Cells[0].Text); TextBox tbN = (TextBox)e.Item.FindControl("tbName3"); CheckBox cb = (CheckBox)e.Item.FindControl("cbIsDef"); if (cb != null && tbN != null) { if (ItemID > 0) { BasePlanSlot bs = BasePlanSlot.Load(ItemID); bs.IsDefault = cb.Checked; bs.Name = tbN.Text; BasePlanSlot.Update(bs); } else { BasePlanSlot.Create(tbN.Text, cb.Checked); } } dgPlanSlot.EditItemIndex = -1; BindDG(); }