示例#1
0
        protected void ProductGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string strID   = e.CommandArgument.ToString();
            string strName = e.CommandName.ToLower();

            switch (strName)
            {
            case "_edit":
                divAddEdit.Visible      = true;
                txtProductId.Visible    = false;
                divGridView.Visible     = false;
                HiddenField_value.Value = strID;
                LoadDataToEdit();
                break;

            case "_delete":
                try
                {
                    logicData.DeleteProductByID(Convert.ToInt32(strID));
                    IbIDisplay.Visible = false;
                    BindingProductData();
                }
                catch (Exception)
                {
                    IbIDisplay.Visible = true;
                    IbIDisplay.Text    = "You can not delete this product!";
                }
                break;
            }
        }
        public ActionResult Delete(string ID)
        {
            ResponseMsg response = new ResponseMsg();

            if (Convert.ToInt32(ID) > 0)
            {
                if (!ProductLogic.DeleteProductByID(ID))
                {
                    response.IsSuccess     = true;
                    response.ResponseValue = "";
                }
            }
            return(Json(response, JsonRequestBehavior.AllowGet));
        }