UZIERSKI UZIERSKI - 1 year ago 78 Question

How to convert this to C# properly?

How Do I convert this line of code to c# properly as the

cannot be used like a method.

Dim RecordValue As Int32 = grdList.SelectedRows(0).DataBoundItem.Item(_ValueMember)

Answer Source

The DataBoundItem is typed as Object, you cannot apply an indexing to this property. Instead if you have binded a DataTable/DataView then you can cast the DataBoundItem to the appropriate object and then, if that class offers indexing you can use indexing

DataRowView rowView = grdList.SelectedRows[0].DataBoundItem as DataRowView;
int recordValue = Convert.ToInt32(rowView[_ValueMember]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download