无法从GridView中获取行值 [英] Can't get row values from GridView

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

问题描述

这是我使用的循环。我得到的行数和列数正确回来,所以我假设我是正确的结合。

This is the loop I'm using. I get the correct number of rows and columns back, so I'm assuming I'm binding correctly.

文本总是空空的。为什么呢?

However Text is always empty. Why?

for (int i = 0; i < GridView1.Rows.Count; i++)
{
    for (int k = 0; k < GridView1.Columns.Count; k++)
    {
        string cellText = GridView1.Rows[i].Cells[k].Text;
    }
}

我已经找到了几个<一个href=\"http://stackoverflow.com/questions/437137/cant-get-values-from-rows-cells-in-gridview\">pointers但他们没有帮助。

修改1

这是我的GridView与一个记录

This is my GridView with one record

唯一的空值是根据责任。

The only empty value is under Responsibility.

从下面伊赫桑萨贾德的回答,我明白我的code总是会得到最后的价值,即经典。

From Ehsan Sajjad's answer below, I understand that my code would always get the last value, i.e. "Classics".

这是否正确?

如果是的话,为什么我得到空的文本对所有列?

If it is, then why am I getting empty Text for all columns?

编辑2

我已经解决了它自己。感谢那些谁在这个线程帮助。请参阅下面我自己的答案。

I've solved it myself. Thanks to those who helped in this thread. See my own answer below.

推荐答案

我的GridView控件使用 DynamicFields

My gridview was using DynamicFields.

解决方案是简单地替代所有我的 DynamicFields 标准绑定列和BOOM所有的数据都在那里。

The solution was simply to replace all my DynamicFields with standard BoundFields and BOOM all the data was there.

我不会使用 DynamicData 框架下一次,这是肯定的。

Next time I won't be using DynamicData framework, that's for sure.

<一个href=\"http://stackoverflow.com/questions/27315951/gridview-empty-rows-when-exporting-to-csv-solved\">On这个其他线程你可以找到我的原问题的完整场景。

On this other thread you can find the complete scenario of my original problem.

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

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