日期:2014-05-17 浏览次数:20553 次
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextInfo info = new TextInfo();
info.Id = Convert.ToInt32((this.GridView1.Rows[e.RowIndex].Cells[0].Text.ToString()));
// info.Id =Convert.ToInt32(((TextBox)this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text.ToString());
info.Name = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[1].Controls[0]).Text.ToString();
info.Pass = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[2].Controls[0]).Text.ToString();
info.Title = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[3].Controls[0]).Text.ToString();
info.Meat = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[4].Controls[0]).Text.ToString();
BText.UpdataAll(info);
this.GridView1.EditIndex = -1;
Bind();
}
------解决方案--------------------
asp.net为了节省空间,并没有缓存所绑定数据的完整的值。你如果想灵活取得任意列的值,应该设置其DataKeyNames属性,然后在你想获得列值之前,首先访问 DataKeys 集合来获得那一行的索引键值,然后从后台数据中单独查询到原始记录,来获得其它列的原始值。
如果是非常固定的列值(而不是任意列值),那么你可以绑定到自定义的属性上。例如
<asp:Button runat="server" 我的值='<%# Eval("field") %>' Text="删除" .....
------解决方案--------------------
/..
.....
LZ 是刚学么?