2013-04-04 105 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) 
{ 

}