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 = "禁用";
                }

         }

  • 相关阅读:
    Linux 开发之线程条件锁那些事
    Linux 开发之线程条件锁那些事
    Linux 开发之线程条件锁那些事
    洛谷3919:可持久化数组——题解
    洛谷3919:可持久化数组——题解
    洛谷3919:可持久化数组——题解
    洛谷3919:可持久化数组——题解
    长篇干货|以太坊智能合约 —— 最佳安全开发指南(附代码)
    长篇干货|以太坊智能合约 —— 最佳安全开发指南(附代码)
    长篇干货|以太坊智能合约 —— 最佳安全开发指南(附代码)
  • 原文地址:https://www.cnblogs.com/wuhuisheng/p/2015755.html
Copyright © 2011-2022 走看看