如何查找数据行数组的索引 [英] how to find the index of the data row array
本文介绍了如何查找数据行数组的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。
i我正在使用datatable.am过滤数据并存储在datarow中[]
DataRow [] dr = dt1.Select(name ='+ result [k2] +'and school ='+ result1 [k3] +');。
i我循环遍历每一行并显示数据。但是我需要找到datarow []的索引。如何做到这一点任何人帮助我。这是我的代码..
Hi every one.
i am using datatable.am filtering the data and storing in datarow[]
DataRow[] dr = dt1.Select("name='" + result[k2] + "' and school='" + result1[k3] + "'");.
i am looping through the each row and displaying data.but i need to find the index of the datarow[].how to do that any one help me.here is my code..
DataTable dt = ds.Tables[0];
DataRow[] dr = dt.Select("name='" + result[k2] + "' and school='" + result1[k3] + "'");.
foreach (DataRow row in dr)
{
// here i want to find the index
}
推荐答案
尝试:
Try:
int index = dt.Rows.IndexOf(row);
将循环更改为一个会自动生成结果:
Changing the loop to afor
one would automatically produce the result:
for (int index = 0; index < dt.Rows.Count; ++index)
{
// nothing to do here, 'index' is already what you need.
}
这篇关于如何查找数据行数组的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文