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

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

问题描述

我是从一个GridView使用以下code试图获取值:

 的foreach(在this.dgvEstudios.Rows GridViewRow行)
{
    变种的xy = row.Cells [1]。文本;
}

总是得到一个空字符串()从。文本的返回值,为什么这发生?我已设置的EnableViewState 真正


解决方案

细胞在其内部都有控制(例如LiteralControl或超链接)。这就是你应该寻找的。

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天全站免登陆