protected void grdGridView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditField") { hdnOperationType.Value = "Update"; int pkid = Convert.ToInt32(e.CommandArgument); hdnIdPK.Value = pkid.ToString(); MedicineBAO BAO = new MedicineBAO(); int id = Convert.ToInt32(Session["HospitalId"]); Medicine obj = BAO.GetMedicineDetailsById(pkid, id); if (obj != null) { txtMedicineName.Text = obj.MedicineName; txtMedicineCategory.Text = obj.MedicineCategory; txtRemark.Text = obj.Remark; } pnlAddForm.Visible = true; pnlGrid.Visible = false; } if (e.CommandName == "DeleteField") { int id = Convert.ToInt32(e.CommandArgument); MedicineBAO BAO = new MedicineBAO(); BAO.DeleteMedicine(id); FillGridView(); } }