无法从 GridView 中的行/单元格获取值

编程入门 行业动态 更新时间:2024-10-28 08:20:26
本文介绍了无法从 GridView 中的行/单元格获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我正在尝试使用以下代码从 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-01 10:40:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/828174.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元格   GridView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!