访问DataTable的Cell [英] access a Cell of DataTable

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

问题描述

原谅我,如果这是一个非常愚蠢的问题



i访问DataTable的单元格这样



string value = dataTable.rows [0] [DataColumnName]。ToString();



但它只返回该列名而不是单元格的值



怎么了?



帮助我。谢谢你

解决方案

调试代码和初始化之前检查快速监视数据表单元的确切值是什么。

  //  它应该有效。  
string value = dataTable.rows [ 0 ] [ DataColumnName]。ToString();
// 但您可以试试这个。希望它能够正常工作。
// 您的代码没有任何问题。
// 2作为列索引
string value = dataTable.rows [ 0 ] [ 2 ]的ToString();


forgive me if it is a very silly question

i access Cell of DataTable like this

string value=dataTable.rows[0]["DataColumnName"].ToString();

but it only return that column name not value of the cell

what's wrong?

help me. thank u

解决方案

Debugg code and Before initialization Check in Quick Watch that what exactly value of datatable cell have.

//it should work. 
string value=dataTable.rows[0]["DataColumnName"].ToString();
// but you can try this. hope so it'll work.
// there is nothing wrong with your code.
// 2 as column index
string value=dataTable.rows[0][2].ToString();


这篇关于访问DataTable的Cell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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