在C#在数据表在特定位置处填充数据 [英] Filling data at a particular location in a Data Table in C#
本文介绍了在C#在数据表在特定位置处填充数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用C#和Asp.Net工作。是有可能填充数据表中的一个特定位置。
I am working with C# and Asp.Net. Is it possible to fill a particular location of a Data table.
我有一个数据表中的 DT ,并包含此此类数据。是否有可能,我可以在特定的位置,例如添加一些数据列 的customer2
和行 Shop1
I have a Data Table dt, and is contains this this kind of data. Is it possible I can add some data at particular location e.g. column customer2
and row Shop1
DATA | customer1 | customer2 | customer3 |
-----------------------------------------------
Shop1 | | | |
-----------------------------------------------
Shop2 | | | |
有没有一种方法可以做到这一点。谢谢
Is there is a way to do this. Thanks
推荐答案
您可以针对单个细胞:
dt.Rows[rowIndex][columnIndex]
列可以通过名称,以及需要解决:
The column can be addressed by name as well:
dt.Rows[rowIndex]["customer2"]
记住,输出的类型为对象
,所以你可能需要,如果你想读它的价值将它转换为适当的数据类型。
Mind that the output is of type Object
, so you might need to cast it to the appropriate data type if you want to read its value.
这篇关于在C#在数据表在特定位置处填充数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文