protected void gvPromoCodes_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "status") { LinkButton lbtn = (LinkButton)e.CommandSource; Control ctrl = e.CommandSource as Control; GridViewRow row = ctrl.Parent.NamingContainer as GridViewRow; LinkButton lbtnstatus = (LinkButton)row.FindControl("lbtnstatus"); Label lblstatus = (Label)row.FindControl("lblStatus"); if (lbtnstatus.Text == "Activate") { objBAL = new ClsBAL(); objBAL.ID = Convert.ToInt32(e.CommandArgument); objBAL.status = "1"; objBAL.modifiedBy = Convert.ToInt32(Session["UserID"].ToString()); if (objBAL.UpdatePromoCodeStatus()) { tdmsg.Visible = true; tdmsg.Style.Add("background-color:#6CC417;", ""); lblMainMsg.Text = "Updated Successfully...."; lblMainMsg.ForeColor = System.Drawing.Color.Green; BindPromocodes(); } else { tdmsg.Visible = true; tdmsg.Style.Add("background-color:#E77471;", ""); lblMainMsg.Text = "OOPS Some Problem in updation.Try Later..."; lblMainMsg.ForeColor = System.Drawing.Color.Maroon; } } else if (lbtnstatus.Text == "Deactivate") { objBAL = new ClsBAL(); objBAL.ID = Convert.ToInt32(e.CommandArgument); objBAL.status = "0"; objBAL.modifiedBy = Convert.ToInt32(Session["UserID"].ToString()); if (objBAL.UpdatePromoCodeStatus()) { tdmsg.Visible = true; tdmsg.Style.Add("background-color:#6CC417;", ""); lblMainMsg.Text = "Updated Successfully...."; lblMainMsg.ForeColor = System.Drawing.Color.Green; BindPromocodes(); } else { tdmsg.Visible = true; tdmsg.Style.Add("background-color:#E77471;", ""); lblMainMsg.Text = "OOPS Some Problem in updation.Try Later..."; lblMainMsg.ForeColor = System.Drawing.Color.Maroon; } } } } catch (Exception ex) { throw ex; } }