删除操作后,ASP.NET Gridview不会刷新

时间:2012-08-30 07:50:17

标签: asp.net gridview internet-explorer-8

我有Internet Explorer 8.我有一个asp:GridView,我在其中显示记录和图像按钮来执行删除操作。我正在删除记录并在gridview的RowComand事件上调用BindMethod。问题是删除记录后Internet Explorer不刷新。我已经检查过firefox和chrome。他们工作正常。

这是我的代码: ASPX:

    <asp:GridView ID="grd" runat="server" CssClass="grd" EmptyDataText="No record found."
EnableViewState="true" AutoGenerateColumns="False" AllowPaging="False" 
OnRowCommand="grdView_RowCommand" OnRowDataBound="grdView_RowDataBound" 
OnPageIndexChanging="grdView_PageIndexChanging">
     <Columns>
      bla
      bla
      bla
      bla
      bla
     </Columns>
    </asp:GridView>

背后的代码

private void BindGrid()
{
     string sSQL = "select * from tableName";
     DataTable dt = DAL.getDataTable(sSQL);
     grd.DataSource = dt;
     grd.DataBind();
}

protected void grdView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
      int id= Convert.ToInt32(e.CommandArgument);
      //Deleting record
      bool result = DAL.DeleteRecord(id);
      if(result)
      {
          BindGrid();
      }
}

请告诉我为什么Internet Explorer没有刷新网格,而其他浏览器工作正常。

1 个答案:

答案 0 :(得分:0)

试试这个,当您尝试删除行时,grdView _ RowCommand不会触发。像下面一样使用grdView _ RowDeleting。仅当您的RowCommand绑定

时,grdView _ GridView才会触发
protected void grdView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
  int id= Convert.ToInt32(e.CommandArgument);
  //Deleting record
  bool result = DAL.DeleteRecord(id);
  if(result)
  {
      BindGrid();
  }
}