protected void dtgData_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "edit") { var info = CosoDB.GetInfo(Convert.ToInt32(e.Item.Cells[0].Text)); if (info == null) { cmdEmpty_Click(null, null); return; } txtID.Text = info.Coso_ID.ToString(); txtName.Text = info.Coso_Name; txtDes.Text = info.Coso_Info; txtAvatar.Text = info.Coso_Map; } if (e.CommandName == "del") { try { CosoDB.Delete(Convert.ToInt32(e.Item.Cells[0].Text)); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; cmdEmpty_Click(null, null); } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } } }
protected void cmdUpdate_Click(object sender, EventArgs e) { var info = CosoDB.GetInfo(ConvertUtility.ToInt32(txtID.Text)); if (info == null) { return; } info.Coso_Name = txtName.Text.Trim(); info.Coso_Info = txtDes.Text; info.Coso_Map = txtAvatar.Text; try { CosoDB.Update(info); lblUpdateStatus.Text = MiscUtility.UPDATE_SUCCESS; } catch { lblUpdateStatus.Text = MiscUtility.UPDATE_ERROR; } }