有没有办法在DataRowView
中获取所选DataRow
的索引?
我目前有以下代码
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;
}
答案 0 :(得分:3)
也许试试
int index = dataView.Table.Rows.IndexOf(dataRow.Row)