0

Here is my code for grid row delete using link button but after click its deleted data after page refresh I want delete data on the page without refresh the page i also put update panel in my grid here is my code

protected void gvContent_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if(e.CommandName=="modify")
    {
        GridViewRow row = 
            (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);

        // this find the index of row:
        int RowIndex = row.RowIndex; 

        //this store the  value in varName1:
        int id = Convert.ToInt32(
                   ((Label)row.FindControl("lblContentId")).Text.ToString()); 

        Response.Redirect("ContentManage.aspx?ContentId=" +Convert.ToInt32(id));
    }
    if (e.CommandName == "delete")
    {
        GridViewRow row = (GridViewRow)
                           (((LinkButton)e.CommandSource).NamingContainer);

        // this finds the index of row:
        int RowIndex = row.RowIndex; 

        //this stores the  value in varName1:
        int id = Convert.ToInt32(
                   ((Label)row.FindControl("lblContentId")).Text.ToString()); 

        Content_Data.DeleteContentDetails(id);
        BindGrid();
        UpdatePanel1.Update();
    }
4

2 回答 2

0

您需要使用以下方法将 gvContent 注册为异步回发控件

 void Page_Load()
    {
        if (!IsPostBack)
        {
            ScriptManager1.RegisterAsyncPostBackControl(gvContent);
        }

    }

这将导致您的 Grid 执行异步回发。

希望有帮助

于 2013-04-04T11:06:03.673 回答
0

尝试添加一个空的 RowDeleting 事件

 protected void gvContent_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {

 }
于 2013-05-24T08:02:53.027 回答