how to get selected row after sorting a DataViewGrid ???

C

cmrchs

Hi,

I have a DataViewgrid that is filled with records sorted on a column 'Date'.When double-clicking on a row do I view the selected row in another window. So far so good

But when I sort the DataViewgrid on another column and dbl-click again do I get a different row than the one selected ???

How can I make sure that the selected row is always shown ?

thnx
Chris


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
T

tomi

Hi .. do not use row indexing by numbers but use its DataBound object
property.

Exapmle:

DataGridView dgv = new DataGridView();
DataGridView subdgv = new DataGridView();
dgv.RowEnter += new DataGridViewCellEventHandler(dgv_RowEnter);

void dgv_RowEnter(object sender, DataGridViewCellEventArgs e)
{
subdgv.DataSource =
(DataRowView)dgv.Rows[e.RowIndex].DataBoundItem;
}

you're all set.
 

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