I have a grid view column in which I give the datefomat as dd MMM yyyy HH:mm and in code behind databound I change the time, the same time in database is not shown in the gridview, because of that the date is not displayed in 16 Nov 2011 15:12 format, it is displayed in 16/11/2011 15:12 format, how can i display it in 16 Nov 2011 15:12 format
asp
<asp:BoundField DataField="SendDate"
ItemStyle-Width="15%"
HeaderText="Sent At"
DataFormatString="{0:dd MMM yyyy HH:mm}"
SortExpression="SendDate" />
c#
double timeDifference = Convert.ToDouble(Session["utimezone"].ToString());
e.Row.Cells[5].Text = Convert.ToString(senddate.AddMinutes(timeDifference * 60));
This format should work:
If it’s not working, there could be something else going on. I would make sure that
SendDateis aDateTimefield, and also make sure that you don’t have some logic overriding theDataFormatString.