Getting dataset row from datagrid

R

Ron L

I have a grid that is the list portion of a list & detail set. I am
catching the SelectedIndexChanged event and using
dslistdata.Tables(0).Rows(grdListDisplay.CurrentRowIndex) to get the data
that fills the grid's row from the underlying dataset. This works fine if
the grid hasn't been sorted, but returns the wrong data if the grid has been
sorted. Is there a better way to get the underlying data from the dataset?
I have a number of columns in the dataset that I didn't include in the grid,
so I can't just use the data from the grid.

TIA
Ron L
 
K

Ken Tucker [MVP]

Hi,

dslistdata.tables(0).defaultview.item(grdListDisplay.CurrentRowIndex)
will return a datarowview of that row.

Ken
--------------------
I have a grid that is the list portion of a list & detail set. I am
catching the SelectedIndexChanged event and using
dslistdata.Tables(0).Rows(grdListDisplay.CurrentRowIndex) to get the data
that fills the grid's row from the underlying dataset. This works fine if
the grid hasn't been sorted, but returns the wrong data if the grid has been
sorted. Is there a better way to get the underlying data from the dataset?
I have a number of columns in the dataset that I didn't include in the grid,
so I can't just use the data from the grid.

TIA
Ron L
 
R

Ron L

Ken
Thanks for the suggestion. I tried that and found that it was giving me
a DataRowView when I needed a DataRow to pass along. What I ended up doing
was using the key for the table (which was a hidden column in the row) and
using it in the .Find method to get the correct row to pass along.

Thanks,
Ron L
 

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