I've got a treeview and a datagrid, and depending on which tree node you select, the contents of my datagrid changes. Grid update is done as follows:
DataSet AppsDS = // comes from a stored proc
MyDataGrid.SetDataBinding(AppsDS,"Table");
MyDataGrid.TableStyles.Clear();
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = this.MyDataGrid.DataMember;
MyDataGrid.TableStyles.Add(ts);
// Hide the desired columns..
MyDataGrid.TableStyles[0].GridColumnStyles["ProductId"].Width = 0;
Thats how I populate my grid, but I've noticed that if I re-order the grid by clicking on a column-header, then when I attempt to process the selected row, it picks up the wrong row. E.g This is how I process which row is highlighted when the datagrid is doubleclicked:
DataSet tmpDS = (DataSet)this.MyDataGrid.DataSource;
object ProdId = tmpDS.Tables[0].Rows[MyDataGrid.CurrentCell.RowNumber]["ProductId"];
I've noticed that the CurrentCell.RowNumber isnt correct IF I have re-ordered the grid's contents by clikcing on column headers.
Any ideas how to fix this problem since I dont really want to disable column sorting.