asp.net - How to display only date in GridView when pulling data from a DB? C# -


i pulling data access database show in gridview control on asp.net project. works fine want see if can format data being pulled. currency being truncated xx.xx dollar amounts. dates displaying mm/dd/yyyy hh/mm/ss am/pm

i tried editing database right values (i set currency field "currency" , date field "short date" when pull date still shows them not formatted.

edit: sorry, had take code down

any ideas? thank you

in grid view of yours add property called dataformatstring

dataformatstring examples:

  {0:dd mmmm yyyy}    -    gives 24 february 2006 {0:mmm dd}          -    gives feb 24 (substitue mmm mmmm full month name                           instead of abbreviation)  {0:dd/mm/yy}        -    gives 24/02/06  {0:dd/mm/yyyy}      -    gives 24/02/2006  

sample code

<asp:boundfield headertext="date"                  datafield="sampledate"                  dataformatstring="{0:mm/dd/yyyy}"  > 

msdn boundfield.dataformatstring property


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -