通过单击“取消"按钮在gridview中删除一行 [英] deleting a row in gridview by clicking cancelbutton

查看:72
本文介绍了通过单击“取消"按钮在gridview中删除一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在我的gridview中,我单击了取消"按钮,而我的要求是,如果单击它,它应该显示弹出窗口,即您确定要取消
吗? 如果您单击确定",则应将其删除.如果单击取消",则不得删除数据.


in my gridview i taken the cancel button and my requirement is if we click on that it should display the popup window i.e "are u sure to cancel
the booking" if we click on ok it should delete.if we click on cancel the data must not delete.

protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            FillGridView();

        }
    }

    private void FillGridView()
    {
        try
        {
            DataSet ds = null;
            ConferenceBL confBL = new ConferenceBL();
            ds = confBL.GetConferenceRoom();
            ViewState["ds"] = ds;

            if (ds != null)
            {
                gvconference.Visible = true;
                gvconference.DataSource = ds;
                gvconference.DataBind();


            }
        }
        catch (Exception ex)
        {
            if (log.IsErrorEnabled)
            {
                log.Error(ex.Message);
            }
        }
    }

    protected void gvconference_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        try
       {
         gvconference.PageIndex = e.NewPageIndex;
         FillGridView();
       }

       catch (Exception ex)
       {
           if (log.IsErrorEnabled)
           {
               log.Error(ex.Message);
           }
       }
    }


    protected void gvconference_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            LinkButton l = (LinkButton)e.Row.FindControl("LinkDelete");

            l.Attributes.Add("onclick", "javascript:return " +
                 "confirm('Are you sure you want to delete this record " +
                 DataBinder.Eval(e.Row.DataItem, "EmployeeId") + "')");

        }

    }
    protected void gvconference_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
            int EmployeeId = Convert.ToInt32(e.CommandArgument);// here i am getting the error.
            // Delete the record
            DeleteRecord(EmployeeId);


        }
    }
    protected void gvconference_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int EmployeeId = (int)gvconference.DataKeys[e.RowIndex].Value;
        DeleteRecord(EmployeeId);
    }

    private void DeleteRecord(int EmployeeId)
    {
        ConferenceBL confBL = new ConferenceBL();
        confBL.DeleteConferenceRoom(EmployeeId);

    }
}




请告诉我代码.我需要写的地方.建议我.

在此先谢谢您.




please tell me the code.where i need to write.suggest me.

Thanks in advance.

推荐答案

GridView删除,带有确认 [^ ]

如果我误解了您的问题,请随时纠正我.希望以上
信息会有所帮助.如果您还有其他顾虑,请告诉我.
如果这对您确实有帮助,请不要忘记以
投票并作答
接受.
GridView Delete, with Confirmation[^]

If i misunderstand your question, please feel free to correct me.I hope the above
information will be helpful. If you have more concerns, please let me know.
If this would be really helpful to you then don''t forgot to Vote and Make Answer as
Accepted.


这篇关于通过单击“取消"按钮在gridview中删除一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆