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

这里面的RowIndex 如何也不能引用

2012-06-09 
这里面的RowIndex 怎么也不能引用protected void GridView1_RowUpdated(object sender, GridViewUpdatedEv

这里面的RowIndex 怎么也不能引用
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
  {
  string tea = this.GridView1.DataKeys[e.RowIndex].ToString();
  }
是怎么回事,是不是还哪里需要设置

[解决办法]
protected void gv_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
gv.EditIndex = e.RowIndex;
int id = int.Parse(gv.DataKeys[e.RowIndex].Value.ToString());

gv.EditIndex = -1;
BindData();
}
protected void gv_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
//没有e.RowIndex
}
[解决办法]
楼主事件用的不对吧
[解决办法]
protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
string tea = this.GridView1.DataKeys[e.Row.RowIndex].ToString();
}

[解决办法]
在给GridView绑定数据时,你给GridView设置主键了吗?
GridView1.DataSource="";
GridView1.DataKeyNames=new string[]{"id"};(这里必须和数据库中的字段保持一致)
GridView1.DataBind();

[解决办法]
这个e.RowIndex 在每个事件里面都有不同的,C/S和B/S又有不同。先弄清楚你触发的事件
[解决办法]

protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
string tea = new DataKey(e.Keys).Value.ToString();
}

热点排行