View Single Post
  #2 (permalink)  
Old September 9th, 2007, 04:11 AM
robzyc robzyc is offline
Friend of Wrox
Join Date: Mar 2007
Location: Hampshire, United Kingdom.
Posts: 432
Thanks: 0
Thanked 1 Time in 1 Post

Hi All,

OK, Here's what I have so far. The problem I had was getting the Selected DataSet Position in the GridView. I have been able to get the code working by using a DataView (with a DataSource of the same DataSet as the Form) for the DataGrid DataSource. I then pulled the position from the DataGrid by searching for the ID in the DataView. I then siply set the Form's BindingContext to the same position.

Here's my current code:
// Get the currently Selected ID from the DataGrid.
const int ID_COL_IDX = 0;
int rowIdx = dataGrid.CurrentRowIndex;                
long SelID = (long)dataGrid[rowIdx, ID_COL_IDX];

// Find the ID in the DataView and Set the Form DataSet Position
int dvPos = dataView1.Find(SelID);
this.BindingContext[dsRegister, "Student"].Position = dvPos;
If anyone has any other solutions then I'd love to hear them!


The Developing Developer
Currently Working Towards: MCAD C#
My Blog:
<center>"Nothing can stop the man with the right mental attitude from achieving his goal;
nothing on earth can help the man with the wrong mental attitude".

Thomas Jefferson</center>
Reply With Quote