0

您好,我正在开发一个 asp.net 项目。

我正在使用数据库和gridview。我想在创建每个 gridviewrow 时获取它的第一个单元格的名称。为什么这不起作用?

protected void CustomersGridView_RowCreated(Object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Response.Write(e.Row.Cells[0].Text);
            }
}
4

1 回答 1

0

如果要获取 gridview 每一行第一列的文本,请使用以下代码:-

受保护的无效GridView1_RowDataBound(对象发送者,GridViewRowEventArgs e){

    Response.Write(e.Row.Cells[0].Text);
}
于 2013-01-07T12:56:53.203 回答