473,426 Members | 1,433 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,426 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 6993
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...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.