469,356 Members | 2,599 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

DataView does not recognize 'DESC'

My code specifies a descending sort, but when my form opens the
datagrid is sorted ascending. However the controls that are bound to
the datagrid recognize the row selection *as if* the rows were sorted
descending. For example: If I select the first row, I get the last row
instead.

=== my code snipit ===

Private bmb As BindingManagerBase

Private Sub SetBindings()

Dim dt As DataTable = dataSet1.tblJob
Dim dView As New DataView

dView.Table = dt
dView.Sort = "JobNumber DESC" '<< note the 'DESC'

DataGrid1.DataSource = Nothing '<< see below for why this is here.
DataGrid1.DataSource = dView

'Controls
lblpkJobId.DataBindings.Add("Text", dView, "pkJobId")
txtJobNumber.DataBindings.Add("Text", dView, "JobNumber")
cboCustomerName.DataBindings.Add("Text", dView, "CustomerName")
txtJobDescription.DataBindings.Add("Text", dView, "JobDescription")

bmb = Me.BindingContext(dataSet1.Tables(currentTable))

End Sub
=== end of code ===

why is this????? Help!


Extra information to show the code works :
BTW I have other buttons that execute other code that sorts in other
ways and a button that links back to the method shown above. If I click
those buttons to sort in other ways and then click the button that
executes the code above then the sort is descending as it should be.
Strange.
The line containing "DataGrid1.DataSource = Nothing" is present to
"clean up after the previous sort. Another method not shown clears the
databinding of the controls just before the above method above is
executed.

Nov 21 '05 #1
1 1117
Dough,

I don't see it, however maybe we can start to make your code more simple and
use the defaultview in every table and not an extra dataview.
Private bmb As BindingManagerBase

Private Sub SetBindings()

Dim dt As DataTable = dataSet1.tblJob
Dim dView as DataView = dt.defaultview
dView.Sort = "JobNumber DESC" '<< note the 'DESC'

DataGrid1.DataSource = Nothing '<< see below for why this is here.
DataGrid1.DataSource = dView


However I would not see from the code you supplied why it would not work.
(However I can over see as well something of course).

Cor
Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Raymond Lewallen | last post: by
2 posts views Thread by Peter S. Guild | last post: by
11 posts views Thread by Jason L James | last post: by
reply views Thread by tshad | last post: by
1 post views Thread by CARIGAR | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.