在 DataView 中查找 DataRowView 的索引
Find Index of DataRowView in DataView
有没有办法在 DataRow
中获取所选 DataRowView
的索引?
我目前有以下代码
private long GetSelectedIndex(DataView dataView, string searchString)
{
long selectedIndex = 0;
foreach(DataRowView dataRow in dataView)
{
if(dataRow.Row.ItemArray.Contains(searchString)
{
//Do Something.... I've tried everything to get the index out of the dataRow
}
}
return selectedIndex;
}
也许试试
int index = dataView.Table.Rows.IndexOf(dataRow.Row)
有没有办法在 DataRow
中获取所选 DataRowView
的索引?
我目前有以下代码
private long GetSelectedIndex(DataView dataView, string searchString)
{
long selectedIndex = 0;
foreach(DataRowView dataRow in dataView)
{
if(dataRow.Row.ItemArray.Contains(searchString)
{
//Do Something.... I've tried everything to get the index out of the dataRow
}
}
return selectedIndex;
}
也许试试
int index = dataView.Table.Rows.IndexOf(dataRow.Row)