Search code examples
c#sqlsql-servertelerikradgrid

Converting DateTime format to be readable without converting to a varchar


In my RadGrid my date is displayed like this:

AUG-14 1:57:00 PM-01

(Maybe becuase the web page is right to left) when it should look like this:

2014-08-01 13:57:00 

(This is how it looks in the Database when selected) The reason I cannot convert it is because I need the sorting option, the sorting won't work well if it is not of DateTime Format.


Solution

  • To format a date inside a Radgrid, try using the DataFormatString

    <MasterTableView>                                                         
        <Columns>                                    
            <radG:GridBoundColumn HeaderText="My Date Field" 
                DataField ="myDateField" 
                DataFormatString="{0:yyyy-MM-dd HH:mm:ss}"></radG:GridBoundColumn>  
         </Columns>                                                    
     </MasterTableView>