DateTime in DataGrid

Danielx

New Member
Does anyone know how to format a datetime bound column in a datagrid. Is there a particular string i can put in the format string of the property builder to do this? right now it's coming up with the default time of 12:00:00I haven't been successfull in modifying the databinder myself. I have been using a datatable with datarows and datacolumns, then binding that to the datagrid. You can very easily then do something like (using a datareader) dr.getdatetime(0).toshortdatestring.&nbsp;<BR>You can add the dataformatstring property to your bound column as follows:<BR><BR><ASP:BoundColumn HeaderText = "Date" <BR> DataField = "rDate"<BR> DataFormatString = "{0:d}"<BR> SortExpression = "rDate" /><BR><BR>This will give you a standard "short date" format (2/23/2002). For a long data format, use a capital D instead of lower case.<BR><BR>Tom T
 
Back
Top