datagrid 在线更新时找不到隐藏列的值

来源:百度知道 编辑:UC知道 时间:2024/06/28 10:42:21
protected void DgEssay_UpdateCommand(object source, DataGridCommandEventArgs e)
{
string id = ((TextBox)e.Item.Cells[0].Controls[0]).Text;
用这个这不到隐藏的id列的值
我在用datagrid 实现在线编辑时 隐藏了主键列,在更新时用e.Item.Cells[0].Text无法获得该列的值
protected void DgEssay_UpdateCommand(object source, DataGridCommandEventArgs e)
{
string id = e.Item.Cells[0].Text;

Controls[0]是干吗的,难道cell里面还放着控件?
直接在datagrid设置该列的Visible=False,然后用
e.Item.Cells[0].Text就可以了

这个方法,我用过的啊,是不是第一列本身就没有绑定数据呢