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

Best way to show only time and sort

2 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 27 Aug 2012, 05:21 PM
I have a column that is a datetime but I only want to show time. I tried dataformatstring="{0:H:mm:ss}" but that didn't work. So, I went into my code behind and took the column and formatted it myself.
   Dim nt = ""
                    If (reader("NextContactTime").ToString <> "") Then
                        Dim tempTime As New DateTime
                        tempTime = reader("NextContactTime")
                        nt = tempTime.ToShortTimeString
                    End If

I then add nt to the data table that I bind my grid with. The problem is, when I use the built in sort function, it doesn't sort properly. I have the column type defined as datetime in my data table and I also made sure all of the days are the same. I.e. only the time is different they all are 01/01/2012 9:30:00 01/01/2012 9:45:00

What is the best way to show just time in a column and allow it to be sorted?

2 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 29 Aug 2012, 02:25 PM
Hello,

Please note that sorting depends on the data type of the specific field and in case you need to sort string type of column as DateTime content, it is obligatory to create a new field with the mentioned data type to use the default sorting functionality of RadGrid for DateTime type.

In addition, you could check out the following thread:
http://www.telerik.com/community/forums/aspnet-ajax/grid/sort-the-date-column-in-radgrid-on-clicking-of-the-header.aspx

I hope this will prove helpful.

Greetings,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
gezim
Top achievements
Rank 1
answered on 29 Aug 2012, 02:51 PM
Hi Eyup,
I'm having problem to refresh grid on updatecommand, this error is happening when I put radgrid into UpdatePanel to refresh data from one combobox outside which is outside grid, can you help me please? Thanks.
Tags
Grid
Asked by
Web Services
Top achievements
Rank 2
Answers by
Eyup
Telerik team
gezim
Top achievements
Rank 1
Share this question
or