1
votes

I want to sort a DataGridView by columns.

I m using SQL to fill my DataTable, to simplify lets assume that the query is :

SELECT X, Y, Z
FROM Table

After that, I initialize the DataGridView DataSource :

myDataGridView.DataSource = myDataTable

In this case, when i click on the column head of the DataGridView, it works just fine. But when I try to decode one filed, the exception bellow occures :

System.ArgumentException: [DECODE(X) is not a valid string input sorting....

The query that raises the issue :

SELECT DECODE(X, '0', 'No', '1', 'Yes'), Y, Z
FROM Table

Any Ideas Please ?

1

1 Answers

1
votes

I had just to use an Alias to rename the column.

What I did understand from this problem is that the DataTable use the name DECODE(X) instead of X.

So the query should be :

SELECT DECODE(X, '0', 'No', '1', 'Yes') AS X, Y, Z
FROM Table