protected void btnAction_Click(object sender, EventArgs e) { string query; try { DataAccessLayer dao = new DataAccessLayer(); if (!String.IsNullOrEmpty(Request.QueryString["id"])) { // Query string value is there so now use it param = Convert.ToInt32(Request.QueryString["id"]); } if (!String.IsNullOrEmpty(Request.QueryString["status"])) { // Query string value is there so now use it status = Convert.ToInt32(Request.QueryString["status"]); //approved unapproved deleisted int approved = 1; int unapproved = 2; switch (status) { case 1: query = "UPDATE tblProperties SET propertyApproved=" + unapproved + " WHERE propertyID = " + param; if (dao.PerformPropertyAction(query) == true) { respMessage.Text = "Property Unapproved"; } break; case 2: query = "UPDATE tblProperties SET propertyApproved=" + approved + " WHERE propertyID = " + param; if (dao.PerformPropertyAction(query) == true) { respMessage.Text = "Property Approved"; } break; case 3: int propertyActive = 1; query = "UPDATE tblProperties SET propertyApproved=" + unapproved + ", propertyStatus=" + propertyActive + " WHERE propertyID = " + param; if (dao.PerformPropertyAction(query) == true) { respMessage.Text = "Property Enlisted as Unapproved"; } break; } } } catch (System.NullReferenceException r) { //exception handling } }