473,394 Members | 1,703 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,394 software developers and data experts.

DataView - Integer Sorting

Hi All,

I have used gridview in my application and i m using dataview to sort
the grid. But when i sort the numeric column, dataview sorts it like a
string.

So, after sorting, instead of getting 1,3,11.... i get 1,11,3... in asc
and 3,1,11 in dec..

Anybody has idea regarding this???

Regards,
Mansi Shah.

*** Sent via Developersdex http://www.developersdex.com ***
Dec 11 '07 #1
1 6986
Hi,

I'm afraid I can't reproduce your problem. Given that the numeric column is
of a numeric type, the dataview sorts it correctly and I get 1, 3, 11 as
expected.

DataTable dt = new DataTable();
dt.Columns.Add("Strings", typeof(string));
dt.Columns.Add("Numbers", typeof(Int32));

DataRow dr = dt.NewRow();
dr["Strings"] = "One";
dr["Numbers"] = 1;
dt.Rows.Add(dr);

dr = dt.NewRow();
dr["Strings"] = "Eleven";
dr["Numbers"] = 11;
dt.Rows.Add(dr);

dr = dt.NewRow();
dr["Strings"] = "Three";
dr["Numbers"] = 3;
dt.Rows.Add(dr);

DataView dv = new DataView(dt);
dv.Sort = "Numbers ASC";
grid.DataSource = dv;

--
Happy Coding!
Morten Wennevik [C# MVP]
"Mansi Shah" wrote:
Hi All,

I have used gridview in my application and i m using dataview to sort
the grid. But when i sort the numeric column, dataview sorts it like a
string.

So, after sorting, instead of getting 1,3,11.... i get 1,11,3... in asc
and 3,1,11 in dec..

Anybody has idea regarding this???

Regards,
Mansi Shah.

*** Sent via Developersdex http://www.developersdex.com ***
Dec 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: jwedel_stolo | last post by:
Hi I'm creating a dataview "on the fly" in order to sort some data prior to writing out the information to a MS SQL table I have used two methods in order to determine the sort order of the...
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.