Best way to show only time and sort

3 posts, 0 answers
  1. Web Services
    Web Services avatar
    243 posts
    Member since:
    Apr 2008

    Posted 27 Aug 2012 Link to this post

    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. Eyup
    Admin
    Eyup avatar
    3012 posts

    Posted 29 Aug 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. gezim
    gezim avatar
    19 posts
    Member since:
    Aug 2012

    Posted 29 Aug 2012 Link to this post

    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.
Back to Top