By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,563 Members | 1,180 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,563 IT Pros & Developers. It's quick & easy.

DataView does not recognize 'DESC'

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.