PDA

View Full Version : Date time conversion in bound coulmn datagrid?


ah_bravo
07-01-2008, 09:58 AM
Can any any one help me how to convert coulmn to datetime with specific date format i.e dd/MM/yyyy Any help will be appreciated....
my code is ..

protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{

if (Convert.ToDateTime(e.Item.Cells[7].Text) < DateTime.Today)
{

e.Item.Cells[5].ForeColor = Color.Silver;

}

}

jleone
07-01-2008, 10:30 PM
Go into the properties window for your datagrid. Choose your columns collection property and you can use the DataFormatString of: {0:dd/MM/yyyy}. Be sure to set the HTMLEncode property for this field to be "False" as well in order for it to format that way.