ASP.Net GridView Displaying DateTime value in the format 'dd-MM-yy' [modified]
-
Hi,
'm using a GridView in my website. I want to display DateTime Values using the format "dd/MM/yy". The Problem is that my WebGrid displays some data correctly but not all of them
(Jan 30 2008) is displayed "01-01-08"
(Feb 04 2008) is displayed "02-04-08"
Some code snippets :
<asp:gridview id="invoicesGridView" ..../ > <columns> <asp:boundfield datafield="CmdDate" headertext="Date" sortexpression="Date" DataFormatString="{0:dd/MM/yy}" HtmlEncode="False"> .... </asp:boundfield>
Note : When I tried to set HtmlEncodeFormatString to "False", my web page returns the error message :
Type 'System.Web.UI.WebControls.BoundField' does not have a public property named 'HtmlEncodeFormatString' !!!
Thanks in advance.Rédha.
modified on Monday, February 04, 2008 10:17:28 AM
-
Hi,
'm using a GridView in my website. I want to display DateTime Values using the format "dd/MM/yy". The Problem is that my WebGrid displays some data correctly but not all of them
(Jan 30 2008) is displayed "01-01-08"
(Feb 04 2008) is displayed "02-04-08"
Some code snippets :
<asp:gridview id="invoicesGridView" ..../ > <columns> <asp:boundfield datafield="CmdDate" headertext="Date" sortexpression="Date" DataFormatString="{0:dd/MM/yy}" HtmlEncode="False"> .... </asp:boundfield>
Note : When I tried to set HtmlEncodeFormatString to "False", my web page returns the error message :
Type 'System.Web.UI.WebControls.BoundField' does not have a public property named 'HtmlEncodeFormatString' !!!
Thanks in advance.Rédha.
modified on Monday, February 04, 2008 10:17:28 AM
have you check your data in your database that been bind to your gridview ? i put the same code in with you in my project, and it works just fine my code : asp:boundfield headertext="Preferred Date to Call" datafield="CallPreferredDate" sortexpression="CallPreferredDate" DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="false" itemstyle width="25%" asp:boundfield hope it helps nb:what the heck in the worls, if i put some code in this text editor, my code will not be shown?
-
have you check your data in your database that been bind to your gridview ? i put the same code in with you in my project, and it works just fine my code : asp:boundfield headertext="Preferred Date to Call" datafield="CallPreferredDate" sortexpression="CallPreferredDate" DataFormatString="{0:dd-MMM-yyyy}" HtmlEncode="false" itemstyle width="25%" asp:boundfield hope it helps nb:what the heck in the worls, if i put some code in this text editor, my code will not be shown?
In my laptop, it works fine but the problem occured when I hosted it !! :( I will Keep the default values set for the Date Column and use the RowDatabound Event, it should works !! Thank You boku NB. To display HTML Code, you have to disable the "Ignore HTML tags in this message (good for code snippets)" checkbox bellow the text editor !!
Rédha.
-
In my laptop, it works fine but the problem occured when I hosted it !! :( I will Keep the default values set for the Date Column and use the RowDatabound Event, it should works !! Thank You boku NB. To display HTML Code, you have to disable the "Ignore HTML tags in this message (good for code snippets)" checkbox bellow the text editor !!
Rédha.