首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

GridView的更新事件 贴了一天了没有人理 求指教

2012-06-05 
GridView的更新事件 在线等 贴了一天了没有人理 求指教啊//更新事件protected void xgvRealtionList_RowUp

GridView的更新事件 在线等 贴了一天了没有人理 求指教啊
//更新事件
protected void xgvRealtionList_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
  GridViewRow row = (GridViewRow)xgvRealtionList.Rows[e.RowIndex];
  TextBox txteeName = row.FindControl("txteeName") as TextBox;
  TextBox txterName = row.FindControl("txterName") as TextBox;
  TextBox txtdeName = row.FindControl("txtdeName") as TextBox;
  TextBox txtewName = row.FindControl("txtewName") as TextBox;
  //获取到要更新的内容后如何进行更新,我的数据源是DataTable, DataTable中的数据是从Execl表格中获取
  //也就是说我的数据更新要在DataTable中执行,请帮小弟写出源码
   
}

[解决办法]
DataRow[] arrDr = dt.Select("条件"); -- 最好是主键,查出DataTable中唯一一条数据
DataRow dr = arrDr[0];
dr.BeginEdit();
GridViewRow row = (GridViewRow)xgvRealtionList.Rows[e.RowIndex];
TextBox txteeName = row.FindControl("txteeName") as TextBox;
TextBox txterName = row.FindControl("txterName") as TextBox;
TextBox txtdeName = row.FindControl("txtdeName") as TextBox;
TextBox txtewName = row.FindControl("txtewName") as TextBox;
dr["字段名"] = txteeName.Text;
....给dr要修改的字段赋值
dr.EndEdit();
dt.AcceptChange();

热点排行