是否有一种方法可以在DataRow
中获取所选DataRowView
的索引?
i当前有以下代码
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)