我期待检索的值是绑定到一个sqlexecute查询datagrid。
defects.DefectsDataGrid.DataContext = searchQuery.ExecuteReader();
字符串
然后,我使用SelectedCellsChanged事件对选定的DataGridRow执行一些操作。
当我在中放置断点时,我可以看到System.Data.Common.DataRecordInternal > Non-public Members > _Values下面的值。但我不确定如何引用_Values。
代码
private void DefectsDataGrid_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
{
//Retrieve selected row
var rows = DefectsDataGrid.SelectedItems;
//This tells me I have one row, which is of type System.Data.Common.DataRecordInternal
//How do I retrieve the values from this type?
}
型
2条答案
按热度按时间dgjrabp21#
字符串
我将上面的代码更改为下面的代码,这将数据类型改为DataRowView,而不是DataRecordInternal
型
这使我能够轻松地引用事件中的行。
型
s71maibg2#
看起来你需要使用
DataReader
将你的记录转换为IDataRecord
。请参阅this answer