zoukankan      html  css  js  c++  java
  • GridView中使用LinkButton添加启用禁用功能

    菜鸟学习

    前台

    <asp:LinkButton ID="lkBtnStart" runat="server" CommandArgument='<%# Eval("es_status") +"&"+ Eval("es_No") %>' ForeColor="Red" Text='<%# Eval("es_status") %>' CommandName="UpStart">LinkButton</asp:LinkButton>

    后台

    protected void gvData_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Del")
            {
                string o_No = e.CommandArgument.ToString();
                UpdateCriteria uc = new UpdateCriteria(typeof(td_ExperienceShop));
                uc.AddAttributeForUpdate(td_ExperienceShop.ES_STATUS, 0);//禁用此门店
                Condition con = uc.GetNewCondition();
                con.AddEqualTo(td_ExperienceShop.ES_NO, o_No);

                if (uc.Perform() > 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('此删除为假删除,信息禁用成功!')", true);
                    this.GridViewBind();
                    return;
                }
                else
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('信息禁用失败!')", true);
                    return;
                }
            }
            if (e.CommandName == "UpStart")
            {
                int j = 0;
                string temp=e.CommandArgument.ToString();
                string[] estr = temp.Split('&');
                string start = estr[0];
                string esNo = estr[1];

                if (start == "0")
                {
                    j = 1;
                }

                int k=ExperienceShopInfo.UpdateExperStatusByNo(j.ToString(),esNo);

                if (k > 0)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('门店状态修改成功!')", true);
                    GridViewBind();
                    return;
                }

    ////在此事件中转换类型为中文

    protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //LinkButton lbtnDelete = (LinkButton)e.Row.FindControl("ibtnDelete");
                //lbtnDelete.Attributes.Add("onclick", "return confirm('确认要删除此门店信息吗?')");
                LinkButton lbtn = (LinkButton)e.Row.Cells[9].FindControl("lkBtnStart");
                if (lbtn.Text == "1")
                {
                    lbtn.Text = "启用";
                }
                else
                {
                    lbtn.Text = "禁用";
                }

         }

  • 相关阅读:
    一行代码搞定Dubbo接口调用
    测试周期内测试进度报告规范
    jq 一个强悍的json格式化查看工具
    浅析Docker容器的应用场景
    HDU 4432 Sum of divisors (水题,进制转换)
    HDU 4431 Mahjong (DFS,暴力枚举,剪枝)
    CodeForces 589B Layer Cake (暴力)
    CodeForces 589J Cleaner Robot (DFS,或BFS)
    CodeForces 589I Lottery (暴力,水题)
    CodeForces 589D Boulevard (数学,相遇)
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2015755.html
Copyright © 2011-2022 走看看