[导入]关于DATAGRID数据更改时点2次/行号跟不准/失去焦点/丢失e等一系列问题的解决办法:

首先把数据连接/dataadater等信息全放到void bindgrid中,其他地方不用if(!ISPOSTBACK),在PAGELOAD的时候只用个
   if (!IsPostBack)
   {
       BindGrid();
   }
---------------------------------------------------------------------------------
例如:  private void Page_Load(object sender, System.EventArgs e)
  { if (!IsPostBack)
   {BindGrid();}
  }
  private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  { DataGrid1.EditItemIndex = e.Item.ItemIndex;
   BindGrid();
  }
  private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
  { DataGrid1.EditItemIndex = -1;
   BindGrid();
  }
  void BindGrid()
  { oleDbDataAdapter1.Fill(dataSet11);
   DataGrid1.DataBind();
  }

文章来源:http://dotnet.mblogger.cn/zeusvenus/posts/7260.aspx

posted on 2005-06-24 05:42  Zeus  阅读(212)  评论(0编辑  收藏  举报

导航