SelectedRows 和 DataBoundItem 不能像 c# 方法一样使用
SelectedRows and DataBoundItem cannot be used like a method c#
如何将这行代码正确转换为 c#,因为 SelectedRows
和 DataBoundItem
不能像方法一样使用。
Dim RecordValue As Int32 = grdList.SelectedRows(0).DataBoundItem.Item(_ValueMember)
DataBoundItem 的类型为对象,您无法对此 属性 应用索引。相反,如果您绑定了 DataTable/DataView,那么您可以将 DataBoundItem 转换为适当的对象,然后,如果 class 提供索引,您可以使用 indexing
DataRowView rowView = grdList.SelectedRows[0].DataBoundItem as DataRowView;
int recordValue = Convert.ToInt32(rowView[_ValueMember]);
如何将这行代码正确转换为 c#,因为 SelectedRows
和 DataBoundItem
不能像方法一样使用。
Dim RecordValue As Int32 = grdList.SelectedRows(0).DataBoundItem.Item(_ValueMember)
DataBoundItem 的类型为对象,您无法对此 属性 应用索引。相反,如果您绑定了 DataTable/DataView,那么您可以将 DataBoundItem 转换为适当的对象,然后,如果 class 提供索引,您可以使用 indexing
DataRowView rowView = grdList.SelectedRows[0].DataBoundItem as DataRowView;
int recordValue = Convert.ToInt32(rowView[_ValueMember]);