Solved

Sorting datatable problem

Posted on 2009-04-09
6
264 Views
Last Modified: 2013-08-03
Hi,

I create an empty datable then fill data to it.
Then I bind it to datagridview.
The display at datagridview is fine, order by "TrsDate, DOrK).

Then I print the data to excel using datatable.
dtTable.DefaultView.Sort = "TrsDate, DOrK"

For each dtRow as datarow in dtTable.Rows
     Print
Next

The problem is the ouput seq is not as I expected.

What's the problem?

Thank you.
0
Comment
Question by:emi_sastra
  • 3
  • 3
6 Comments
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24113292
I don't think that actually sorts the data, but just sorts the display of the data (someone correct me if I'm wrong as I'm not a big DataGridView user.  You could sort the data before it hits the DGV (ie. add an ORDER BY clause to the SELECT statement that retrieves the data the DGV is binding to).
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24113314
Hi,

Please provide sample to do it?

Thank you.
0
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24113450
Sorry friend, I don't have time to do that.  If you have other specific questions I'll try to help though.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Author Comment

by:emi_sastra
ID: 24113495
My question is quite obvious, unless you don't understand since you are not familiar with it.

I have found the answer over the net.

Thank you for your time.
0
 
LVL 1

Accepted Solution

by:
emi_sastra earned 0 total points
ID: 24113511
Just change:

dtTable.DefaultView.Sort = "TrsDate, DOrK"

For each dtRow as datarow in dtTable.Rows
     Print
Next

To :

 Dim dv As New DataView(dtTable)

 dv.Sort = "TrsDate, DOrK"

 For Each dtRow As DataRowView In dv
     Print
 Next

Isn't it obvious and simple solution? Just spend a little time if you are familiar with it.

Thank you.
0
 
LVL 5

Expert Comment

by:brandonvmoore
ID: 24113515
Well whoopity doo for you.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question