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

Problem with GridView sorting on date column.

3 Answers 153 Views
GridView
This is a migrated thread and some comments may be shown as answers.
RAGHAVENDRA
Top achievements
Rank 1
RAGHAVENDRA asked on 13 Jan 2011, 04:22 PM
I have some dates in a Rad GridView. I can never get to sort them in the correct order. I clicked on the property builder and set the sort order as Desecending for that particular date column. Is this a problem everyone face or any thing else  needs to be done. How do we add a sort expression for a rad grid in winforms. I am using Q3 SP 2010. Thanks a lot for your help.

3 Answers, 1 is accepted

Sort by
0
Richard Slade
Top achievements
Rank 2
answered on 13 Jan 2011, 04:59 PM
Hello,

Please can you try this very simple exmaple in a new project. Then click a few times on the data column header to see the sorting and let me know if that works for you.

Imports Telerik.WinControls
Imports Telerik.WinControls.UI
Imports System.ComponentModel
  
  
Public Class Form1
  
    Private Sub Form1_Load(ByVal sender As System.Object,
                           ByVal e As System.EventArgs) Handles MyBase.Load
  
        Me.RadGridView1.EnableSorting = True
  
        Dim people As New List(Of MyObject)
        people.Add(New MyObject("name 1", 10, Now.AddDays(1)))
        people.Add(New MyObject("name 2", 20, Now.AddDays(2)))
        people.Add(New MyObject("name 3", 30, Now.AddDays(3)))
        people.Add(New MyObject("name 4", 40, Now.AddDays(4)))
        people.Add(New MyObject("name 5", 50, Now.AddDays(5)))
        people.Add(New MyObject("name 6", 60, Now.AddDays(6)))
  
        Me.RadGridView1.DataSource = people
  
    End Sub
  
End Class
  
  
Public Class MyObject
    Public Sub New(ByVal name As String, ByVal number1 As Integer, ByVal myDate As DateTime)
        Me.Name = name
        Me.Number1 = number1
        Me.MyDate = myDate
    End Sub
  
    Public Property Name As String
    Public Property Number1 As Integer
    Public Property MyDate As DateTime
End Class

Thanks
Richard
0
RAGHAVENDRA
Top achievements
Rank 1
answered on 13 Jan 2011, 05:16 PM
Richard thanks a lot for your help, i figured that i am using a text box column to display the date instead of a datetimecolumn. So the sorting doesnt work as I expect it to. Now its working fine. 
0
Richard Slade
Top achievements
Rank 2
answered on 13 Jan 2011, 05:52 PM
You're welcome. If you found that my example helped please remember to mark as answer
Thanks
Richard
Tags
GridView
Asked by
RAGHAVENDRA
Top achievements
Rank 1
Answers by
Richard Slade
Top achievements
Rank 2
RAGHAVENDRA
Top achievements
Rank 1
Share this question
or