Data from datatable after datagrid sorting

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Data from datatable after datagrid sorting

 
0
  #1
Jun 15th, 2007
I have a datatable (sqltable) and a datagrid (dgData)

if the user click the datagrid header the grid changes sort order
but when i try to get
  1. Dim Row As DataRow
  2. Row = sqlTable.Rows(dgData.CurrentCell.RowIndex)
or
  1. Dim Row As DataRow = sqlTable.Rows(e.RowIndex)

the row returned is not the row selected in the datagrid

any ideas how to do this?

Thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 5
Reputation: chriswininger is an unknown quantity at this point 
Solved Threads: 0
chriswininger chriswininger is offline Offline
Newbie Poster

Re: Data from datatable after datagrid sorting

 
0
  #2
Dec 16th, 2008
Try this:

Dim bm As BindingManagerBase = _
dgData.BindingContext(dgData.DataSource, dgData.DataMember)

Dim Row As DataRow = bm.Current.Row
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 169
Reputation: ptaylor965 is an unknown quantity at this point 
Solved Threads: 19
Sponsor
ptaylor965's Avatar
ptaylor965 ptaylor965 is offline Offline
Junior Poster

Re: Data from datatable after datagrid sorting

 
0
  #3
Dec 16th, 2008
Thanks for the post but since the question was asked on Jun 15th, 2007 I have found an easy answer

  1. Protected dvMyData as New DataView
Then
  1. dvMyData.Table = MyDataTable
  2. dgData.DataSource = dvMyData
Then I can use
  1. dim Row as DataRow = dvMyData(dgDataGrid.CurrentRow.Index)
This has been the best and I have been using it for several months now.


Thanks
Peter
Peter Taylor
Visual Basic.NET Application Developer

TaylorsNet
http://www.taylorsnet.co.uk
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC