2013-04-04 106 views
0

這是我的網格行刪除使用鏈接按鈕的代碼,但在頁面刷新後單擊其刪除的數據後我想要刪除頁面上的數據而不刷新頁面我也把更新面板放在我的這裏電網是我的代碼在gridview頁面刷新後刪除鏈接按鈕的工作

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(); 
    } 

回答

0

您需要使用跟隨着

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

    } 

這將導致你的網格進行異步後背上註冊gvContentas異步後回控制。

希望幫助

+0

這個代碼回發前申請? – achievers 2013-04-05 06:03:22

+0

我更新了代碼 – 2013-04-05 06:33:18

0

嘗試添加一個空的RowDeleting事件

protected void gvContent_RowDeleting(object sender, GridViewDeleteEventArgs e) 
{ 

}