Current row in a datagrid/dataview

G

Guest

I have a datagrid, based on a dataview (filled with dataset data from SQL
server).

The dataview contains an ID field, but this field isn't in the datagrid.

How can I get the ID associated with the current selected row in the datagrid?

Possible?

Thanks in advance,
Amber
 
B

Bart Mermuys

Hi,

amber said:
I have a datagrid, based on a dataview (filled with dataset data from SQL
server).

The dataview contains an ID field, but this field isn't in the datagrid.

How can I get the ID associated with the current selected row in the
datagrid?

Possible?

You can get the current DataRowView from CurrencyManager.Current (returned
from BindingContext(...)):

Dim drv As DataRowView = DirectCast( BindingContext( _
DataGrid1.DataSource, DataGrid1.DataMember).Current, _
DataRowView)

Dim ID As Integer = CInt(drv["ID"]);


HTH,
Greetings
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top