예제 #1
0
        protected void rbtProductCategories_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            DataTable dt = new DataTable();

            switch (e.CommandName.ToString())
            {
            case "update":
                dt = _product.GetListByCategoryID(int.Parse(e.CommandArgument.ToString()));

                if (dt.Rows.Count > 0)
                {
                    //Thao tác update
                    txtProductName.Text = dt.Rows[0]["vName"].ToString();
                    txtOrder.Text       = dt.Rows[0]["vOrder"].ToString();
                    chkActive.Checked   = ((bool)dt.Rows[0]["Active"]) ? true : false;

                    hdProID.Value  = e.CommandArgument.ToString();
                    hdInsert.Value = "update";

                    mul.ActiveViewIndex = 1;
                }
                break;

            case "delete":
                dt = _product.GetListByCategoryID(int.Parse(e.CommandArgument.ToString()));

                if (dt.Rows.Count > 0)
                {
                    //Thao tác xóa
                    _product.Delete(int.Parse(e.CommandArgument.ToString()));
                    Response.Redirect(Request.Url.ToString());
                }
                break;
            }
        }