Exemplo n.º 1
0
    protected void gvData_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int    id      = e.CommandArgument.ToArrowInt();
        string command = e.CommandName;

        if (command == "UpdateData")
        {
            GridViewRow drv     = ((GridViewRow)(((LinkButton)(e.CommandSource)).Parent.Parent));
            string      catName = (gvData.Rows[drv.RowIndex].FindControl("tbName") as TextBox).Text;
            string      order   = (gvData.Rows[drv.RowIndex].FindControl("tbOrder") as TextBox).Text;
            if (!catName.IsNullOrEmpty())
            {
                var model = GoodsBLL.SelectGoodsCat(id);
                if (model != null)
                {
                    model.Name      = catName;
                    model.SortOrder = order.ToArrowInt();
                    GoodsBLL.UpdateGoodsCat(model);
                }
            }
        }
        else if (command == "DelData")
        {
            var model = GoodsBLL.SelectGoodsCat(id);
            if (model != null)
            {
                model.IsDel = 1;
                GoodsBLL.UpdateGoodsCat(model);
            }
        }

        BindData();
        MessageBox.Show("操作成功!");
    }