无法从 GridView 中的行/单元格获取值 [英] Can't get values from rows/cells in GridView

查看:26
本文介绍了无法从 GridView 中的行/单元格获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码从 GridView 获取值:

foreach(this.dgvEstudios.Rows 中的GridViewRow 行){var xy = row.Cells[1].Text;}

总是得到一个空字符串("")作为.Text的返回值,为什么会这样?我已将 EnableViewState 设置为 true

解决方案

单元格内部可能有控件(例如 LiteralControl 或 HyperLink).这就是您应该寻找的.

row.Cells[1].Controls 集合,你应该找一下.

I'm trying get values from a GridView using the following code:

foreach (GridViewRow row in this.dgvEstudios.Rows)
{
    var xy = row.Cells[1].Text;
}

Always get a an empty string ("") as the value returned from .Text, why does this happen? I have set EnableViewState to true

解决方案

The cell might have controls inside it (e.g. LiteralControl or an HyperLink). This is what you should be looking for.

row.Cells[1].Controls collection, you should look for.

这篇关于无法从 GridView 中的行/单元格获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆