Hi
I have following problem.
I have a datatable filled with some data. Each row holds its ID (column
named "Row_ID")
DataTable dtTable;
I have a datagrid to which I assign this datatable. I also apply some
styling to this datagrid so I only see some columns from this table
(let's say "Name", "SureName" ... "Row_ID" stays hidden)
//simplified
Datagrig dgGrid;
dgGrid.DataSource = dtTable;
Now datagrid is showing my data. Now, I add simple Event where I want
to display a ID of currently clicked row (no matter it does for each
cell).
private void dgGrid_CurrentCellChanged(object sender, System.EventArgs
e) {
MessageBox.Show(dtTable.Rows[this.BindingContext[dtTable].Position]["Row_ID"]);
}
Everything seems to work OK UNTIL I sort the datagrid (by clicking on
one of the column headers). From this moment ON everything is messed
up, and bindings context position is always a row number.
Can anyone help me with:
How do you get a rowNumber in datasource assigned to some datagrid
after there was some ordering done after this source was assigned to
it?
Thanks a lot in advance!
Tomi