取Gridview的当前行中为什么数据是""的?
lqhly 2010-01-12 11:57:42 系统:sql2005+vs2008.
在一个Gridview中要编辑数据,前主要台位代码:
<asp:CommandField HeaderText="编辑" EditText="编辑" UpdateText="更新" CancelText="取消" ShowEditButton="True" />
<asp:CommandField HeaderText="删除" DeleteText="刪除" ShowDeleteButton="True" />
我需要在删除事件中先选出该行的各字段的内容,然后再决定是否要删除,代码如下:
protected void GridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
s_1 = this.GridView.Rows[e.RowIndex].Cells[0].Text;
s_2 = this.GridView.Rows[e.RowIndex].Cells[1].Text;
s_3 = this.GridView.Rows[e.RowIndex].Cells[2].Text;
}
我调试跟踪时发现e.RowIndex是正确的当前行号,但该行的各个字段的内容都是空的,即s_1="",s_2="",s_3=""
这是为什么?如何才能提出正确的数据?