DataTable和Gridview奇怪的行为。 [英] DataTable and Gridview Strange Behavior.

查看:71
本文介绍了DataTable和Gridview奇怪的行为。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,



我正在通过OLEDBDataAdapter从excelsheet读取数据集中的值,而不是通过数据表将它们添加到gridview中。



假设这些值在两列中,当我在绑定到gridview之前在数据表中看到它时,它显示了确切的两列和正确的数据。



但是如果我尝试检查Gridview的OnRowDatabound事件中的gridview数据,它会显示只有一个单元格在那里......如果我试图通过

获取值



I am reading values in a dataset from a excelsheet through OLEDBDataAdapter and than adding them to a gridview through a datatable.

let say those values are in two columns and when i see at the datatable before binding to gridview, it is showing exact two columns and proper data.

But if i try to check the gridview data in Gridview's "OnRowDatabound" event, it shows that only one cell is there... and if i try to get the values through

e.row.cells[1].text

比它给出的我的错误,





任何想法???

than it gives me error,


Any idea???

推荐答案

问题是绑定字段的缺席,因为我直接使用数据表绑定Gridview,因此它显示了Gridview中的值,



但是没有将它们作为行value是因为gridvi中没有可用的物理行ew,



所以我添加了两个绑定字段,用数据表中获得的值绑定它们,而不是在这里,我很容易获得行单元格值,





感谢所有人的帮助...:)
Problem was the absense of bound fields, as I was binding the Gridview directly with datatable, so it was showing the values in the Gridview,

But was not getting them as row value's because there was no physical row available in the gridview,

So I added two bound fields, binded them with the gained valued in datatable, and than here I am, easily getting row cells valus,


Thanks to all for help... :)


这篇关于DataTable和Gridview奇怪的行为。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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