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

Sorting in dataGrid

I have column of dataType varchar(10).

The values in this column are decimal numbers, 'NUL', OR ''.
(because of 'NUL' and '' values I haven't defined column as decimal(18,2))

When I fill dataGrid and user click sorting on this column, the column is
sorted alphabetically.

So 100,00 is before 2,00.

Is there any option to include somehow, custom sorting, which exclude the
'NUL' and '' fields and sort other fields like numbers?

Thank you for your answer,
Simon
Nov 19 '05 #1
2 1420
Hi Simon,

Suppose the column name is charNum, you can use following query

SELECT * FROM TABLE_NAME
ORDER BY (CASE WHEN charNum IS NULL OR charNum ='' THEN Big_Number ELSE
CAST(charNum AS DECIMAL(18,2)) END)

HTH

Elton Wang
el********@hotmail.com
"simon" wrote:
I have column of dataType varchar(10).

The values in this column are decimal numbers, 'NUL', OR ''.
(because of 'NUL' and '' values I haven't defined column as decimal(18,2))

When I fill dataGrid and user click sorting on this column, the column is
sorted alphabetically.

So 100,00 is before 2,00.

Is there any option to include somehow, custom sorting, which exclude the
'NUL' and '' fields and sort other fields like numbers?

Thank you for your answer,
Simon

Nov 19 '05 #2
Thanks Elton,

that would be one solution.

Other is that I create invisible column in datagrid, which is decimal
dataType and use order by that column.

regards,
Simon

"Elton W" <El****@discussions.microsoft.com> wrote in message
news:C9**********************************@microsof t.com...
Hi Simon,

Suppose the column name is charNum, you can use following query

SELECT * FROM TABLE_NAME
ORDER BY (CASE WHEN charNum IS NULL OR charNum ='' THEN Big_Number ELSE
CAST(charNum AS DECIMAL(18,2)) END)

HTH

Elton Wang
el********@hotmail.com
"simon" wrote:
I have column of dataType varchar(10).

The values in this column are decimal numbers, 'NUL', OR ''.
(because of 'NUL' and '' values I haven't defined column as
decimal(18,2))

When I fill dataGrid and user click sorting on this column, the column is
sorted alphabetically.

So 100,00 is before 2,00.

Is there any option to include somehow, custom sorting, which exclude the
'NUL' and '' fields and sort other fields like numbers?

Thank you for your answer,
Simon

Nov 19 '05 #3

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

Similar topics

12
by: pmud | last post by:
Hi, I am using teh following code for sorting the data grid but it doesnt work. I have set the auto generate columns to false. & set the sort expression for each field as the anme of that...
0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going...
3
by: melanieab | last post by:
Hi, I'm programatically sorting in a datagrid. When a column header is clicked, the sort happens twice for some reason, making it looks like it only sorts in descending order. I can tell it...
1
by: Jeremy | last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
5
by: DKC | last post by:
Hi, Using VB.NET. I have a datagrid having a strongly typed array of objects as its data source. The data from the array of objects is displayed by means of a table style, which is fine, but...
8
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
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
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: 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:
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
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.