This is a migrated thread and some comments may be shown as answers.

sorting with smallint problem

5 Answers 132 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 1
Erik asked on 29 Aug 2007, 01:43 PM
Hi Telerik Team,

I encounter that when i am using the RadGridView to do sorting, for example: i am about to sort 1,2,3,4,5,6,7,8,9,10 in descending manner where the datatype is smallint, the grid will return 9,8,7,6,5,4,3,2,1,10 in which i expected 10,9,8,7,6.....,1 since it is smallint datatype.

Pls Help. Thanks

5 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 29 Aug 2007, 04:25 PM
Hello eriksurya,

Your problem seems to be related to the fact that the grid sorts the column as if they are of type string. Check your data source to confirm this. If you manually add the column (through the RadGridView.MasterGridViewTemplate.Columns collection), be sure to create the correct column type.
 

Regards,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Erik
Top achievements
Rank 1
answered on 30 Aug 2007, 01:06 AM
Thanks for the quick reply.
I confirm that the data type is smallint.
I bounded the table from database to the grid, and sort the column (smallint datatype) using the following code:

mysort = new RadSortExpression
mysort.FieldName = "NOS"
mysort.sortorder = RadSortOrder.Descending
RadGridView1.MasterGridViewTemplate.SortExpressions.Set(mysort)

thanks......
0
Dwight
Telerik team
answered on 03 Sep 2007, 01:19 PM
To confirm what causes the problem, please, check the type of column that is created when binding the grid, then check its DataType.

Here is a sample code:
 
radGridView1.DataSource = bindingSource; 
 
GridViewDataColumn gvdc = radGridView1.MasterGridViewTemplate.Columns["NOS"as GridViewDataColumn; 
 
Debug.WriteLine(string.Format("Column: {0}, Column type: {1}", gvdc.GetType().ToString(), gvdc.DataType.ToString())); 

The output should be something like: Column: GridViewTextBoxColumn, Column type: System.Int16

Please, let us know what the output is, so that we could further investigate the problem.
 

Regards,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Erik
Top achievements
Rank 1
answered on 04 Sep 2007, 07:51 AM
Thanks for the reply

Yes.. the datatype of the column in grid is "System.String"
So, Any suggestion on this issue?
Shouldn't the datatype of the column of the grid follows the datasource?
0
Dwight
Telerik team
answered on 07 Sep 2007, 08:25 AM
Hello eriksurya,

We did locate the problem in the Q1 SP2 release. The fix is available in the Q2 Beta. Please, download the beta and give it a spin.
 

Best,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Erik
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Erik
Top achievements
Rank 1
Share this question
or