Problem with sorting in GridControl

I don't know if this is a problem within Syncfusion or .NET, but I have a GridControl with a column of numbers. In the GridControl Designer so have I set this column to have CellValueType "System.Decimal".

I have a DataView that I use to fill my GridControl with, and use its Sort property to sort the GridControl. However, when I sort I end up with results like: 1, 10, 100, 11, 2, 3 when I want: 1, 2, 3, 10, 11, 100.
I have tried set the column in the DataSet as Decimal as well and then the sort works nice but I can't type in an empty value since I then get an error saying that it's not a valid value for Decimal.

So, I want to be able to sort like 1, 2, 3, 10, 11, 100 and also be able to type in empty values in my cell on the grid.

I'm using Syncfusion 6.4.0.15 and VS 2005.


4 Replies

NA Nisha Arockiya A Syncfusion Team November 27, 2008 09:27 AM UTC

Hi Markus,

Thanks for your interest in Syncfusion Products.

This exceptions is being thrown when trying to parse as a double a value of DBNull into a empty row.

You can add an extra condition to your parse code inorder to handle the DBNull problem.

if(o == DBNull.Value)
{
//do your code for empty values
}


Please let me know if this serve your needs.

Regards,
Nisha



MP Markus Persson November 27, 2008 10:40 AM UTC

Thank you Nisha. This line did the trick for me in my SaveCellFormattedText event.


Me.DataView1(row - 1)(col) = DBNull.Value


If anyone is interested in the whole sub:


Dim col As Integer = CType(sender, GridModel).CurrentCellInfo.ColIndex
Dim row As Integer = CType(sender, GridModel).CurrentCellInfo.RowIndex

If row > 0 And col > 0 Then
If e.Text = "" Then
Me.DataView1(row - 1)(col) = DBNull.Value
Else
Me.DataView1(row - 1)(col) = e.Text
End If
End If




MP Markus Persson November 27, 2008 10:43 AM UTC

Or even shorter...


If row > 0 And col > 0 Then
Me.DataView1(row - 1)(col) = IIf(e.Text = "", DBNull.Value, e.Text)
End If




NA Nisha Arockiya A Syncfusion Team November 27, 2008 12:20 PM UTC


Hi Markus,

Thanks for all the Updates.Please let us know any other concerns.

Regards,
Nisha


Loader.
Up arrow icon