943,954 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 7474
  • VB.NET RSS
Jun 15th, 2007
0

Data from datatable after datagrid sorting

Expand Post »
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
VB.NET Syntax (Toggle Plain Text)
  1. Dim Row As DataRow
  2. Row = sqlTable.Rows(dgData.CurrentCell.RowIndex)
or
VB.NET Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006
Dec 16th, 2008
0

Re: Data from datatable after datagrid sorting

Try this:

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

Dim Row As DataRow = bm.Current.Row
Reputation Points: 20
Solved Threads: 0
Newbie Poster
chriswininger is offline Offline
5 posts
since Dec 2008
Dec 16th, 2008
0

Re: Data from datatable after datagrid sorting

Thanks for the post but since the question was asked on Jun 15th, 2007 I have found an easy answer

VB.NET Syntax (Toggle Plain Text)
  1. Protected dvMyData as New DataView
Then
VB.NET Syntax (Toggle Plain Text)
  1. dvMyData.Table = MyDataTable
  2. dgData.DataSource = dvMyData
Then I can use
VB.NET Syntax (Toggle Plain Text)
  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
Reputation Points: 16
Solved Threads: 19
Junior Poster
ptaylor965 is offline Offline
169 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: scrollbar control that is changing its colour
Next Thread in VB.NET Forum Timeline: Format Number





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC