Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
How does asp treat numbers?
Old 08-14-2008, 08:04 PM How does asp treat numbers?
Extreme Talker

Posts: 176
Trades: 0
I have an database, and one column will have a number 1-10.

When I shop them ordered by that number, will they propery show

1
2
3
4
5
6
7
8
9
10

or do it wrong, like some things do when alphabetizing:

1
10
2
3
4
5
6
7
8
9

What do you think I should do?

Should i do 0-9?

should they be 01, 02, 03, ect.?

There may be more than 10 later.
Skeddles is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-15-2008, 08:16 AM Re: How does asp treat numbers?
Average Talker

Posts: 25
Name: David Hamsterdam
Trades: 0
It depends upon the coding. You can manage it by using if else statement. If you declare it as a char type, the result: 1, 10, 11, 12 ..... but for numbers, the result: 1,2,3,4......
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
cyberseren is offline
Reply With Quote
View Public Profile
 
Old 08-15-2008, 08:27 AM Re: How does asp treat numbers?
Extreme Talker

Posts: 213
Trades: 0
why don't use 01 02 03 04 05 06 07 08 09 10 etc?
I think that will be working in any case.
SeemsOk is offline
Reply With Quote
View Public Profile
 
Old 08-16-2008, 10:37 AM Re: How does asp treat numbers?
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,515
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
IF they are REALLY numbers. It doesn't matter, and they will show in the correct numeric order with or without a leading zero

HOWEVER

If they are strings of number characters you will need a leading zero as then they will be sorted in ASCII value order.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-18-2008, 01:53 AM
itHighway's Avatar
Skilled Talker

Posts: 83
Name: Zeeshan Dar
Location: GUJ
Trades: 0
You have to change the field type to Numeric in database. This is resolve the sorting issue when browsing the products on web interface.

If you are using the MS Access database then you will have to change the field type in database and if MS Sql then you can convert the field type in sql query.
__________________
Zeeshan Dar
itHighway -
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by chrishirst; 08-18-2008 at 03:56 AM.. Reason: followon post merged
itHighway is offline
Reply With Quote
View Public Profile
 
Old 08-18-2008, 06:26 AM Re: How does asp treat numbers?
Super Talker

Posts: 104
Location: http://www.joomladevs.com
Trades: 0
If the column type is Numeric(Integer) then it will give you the results as 1,2,3.. etc and If you have column type Text(Varchar) then it will give you the results as 1,10,2,3... etc
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE


saurabhj is offline
Reply With Quote
View Public Profile Visit saurabhj's homepage!
 
Old 08-19-2008, 04:06 PM Re: How does asp treat numbers?
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Chris Hirst has the right answer. As strings, it goes 1, 2, 20, 25, 3, 35, 4, and so on. If you sort them as numbers, you'll avoid this, and if you must sort them as strings, prefix them to a set width, as 001, 002, 020, and so on.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How does asp treat numbers?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25643 seconds with 12 queries