当GridView处于编辑状态时,需要判断是否继续,并根据判断执行下一步操作

当GridView处于编辑状态时,需要判断是否继续,并根据判断执行下一步操作,做法如下:

两个Button为隐藏,点击Button时先执行后台代码,进行判断,如果是编辑状态,就弹出提示:是否继续,如果继续就把没保存的数据丢失。

代码如下:

 

protected void btnPreviousHiden_Click(object sender, EventArgs e)
    {
        if (gvEmpLanguageSkill.EditIndex != -1 || gvCertificate.EditIndex != -1)
        {
            btnPrevious.Attributes.Add("onclick", "return confirm('" + Resources.AlertMessage.WFEmployeeConfirm+ "');");
            Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>GetClickButton(1);</script>");
            return;
        }
        btnPrevious_Click(sender, e);
    }
    protected void btnNextHiden_Click(object sender, EventArgs e)
    {
        if (gvEmpLanguageSkill.EditIndex != -1 || gvCertificate.EditIndex != -1)
        {
            btnNext.Attributes.Add("onclick", "return confirm('" + Resources.AlertMessage.WFEmployeeConfirm+ "');");
            Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>GetClickButton(2);</script>");
            return;
        }
        btnNext_Click(sender, e);
    }


    /// <summary>
    /// 上一页
    /// </summary>
    protected void btnPrevious_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("WFEmpEduTraining.aspx");
    }

    /// <summary>
    /// 下一页
    /// </summary>
    protected void btnNext_Click(object sender, EventArgs e)
    {
        this.Response.Redirect("WFEmpMaintainExperience.aspx");
    }

 

<asp:Button ID="btnPrevious" runat="server" Text="上一页" Width="80px" OnClick="btnPrevious_Click" Style="display: none" />
                    <asp:Button ID="btnNext" runat="server" Text="下一页" Width="80px" OnClick="btnNext_Click" Style="display: none" />
                    <asp:Button ID="btnPreviousHiden" runat="server" Text="上一页" OnClick="btnPreviousHiden_Click" Width="80px" />
                    <asp:Button ID="btnNextHiden" runat="server" Text="下一页" OnClick="btnNextHiden_Click"
                        Width="80px" />

       

<script>
    function GetClickButton(i)
    {
    if(i=="1")
    {
    document.getElementById('btnPrevious').click();
    }else
    {
    document.getElementById('btnNext').click();
    }
          }
    </script>

阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭