473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1225
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Raymond Lewallen | last post by:
I have a dataview in which the sort property will not sort the dataview. Here's is a simple scenario similar to what I am doing: Class Foo Private Function Retrieve() As DataView ' Returns a...
4
by: Bruce Pullum | last post by:
I have a datagrid that I am using a DataView with. All works great for the sorting of the columns. However, after I sort the column, and then try and select a data row to edit, the row selected...
2
by: Peter S. Guild | last post by:
Hello, I have a simple routine that uses a dataview to hold information. I need to sort these columns by section and then by desc. No matter what I do the dataview will not sort. What am I...
3
by: nish | last post by:
Hi, I have been working on Sorting within a Datagrid that is created programmatically, so everything is created in the code-behind. I have a Template Column that consists of a Header Template....
11
by: Jason L James | last post by:
I have a defaultview of a data table in a typed dataset. When I first populate a tree view with the contents of the dataset the records are in the correct sort order. After adding a new record...
0
by: tshad | last post by:
In my program, I have a dataview that I am sorting (dv.sort) and then making changes to it. I thought I was going to have to re-sort the dataview, but it seems that it was already re-sorted when I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.