Hi,

I set HtmlEncode="False" and DataFormatString="{0:mm/dd/yyyy}" in boundfield of a gridview but the month became 00 (18/00/2008). After removing {0:mm/dd/yyyy} from DataFormatString, the month appeared again (2008-09-18 12:00:00 AM) of course together with the time portion that I wish to get rid of.

Please help. BTW, whart is {0} stands for? Or just a syntax?

<asp:BoundField DataField="EstimateCompleteDate" HeaderText="EstimateCompleteDate"
SortExpression="EstimateCompleteDate" DataFormatString="{0:mm/dd/yyyy}" HtmlEncode="False" />
<asp:BoundField DataField="ActualCompleteDate" HeaderText="ActualCompleteDate" SortExpression="ActualCompleteDate" DataFormatString="{0:mm/dd/yyyy}" HtmlEncode="False" />

Thanks in advance.

Hi,

I am providing one more method..

You can do it on server side if u want. Just do like this in Item Bound of your gird

e.Item.Cells(0).Text = Format(Date.Parse(e.Item.Cells(0).Text),"MM/dd/yyyy")

this cell is your date cell.

Hope this will help you. :)

Hi,

I'm new to ASP.net. I use VWD to ceate gridview for editing records. I don't have much coding on .vb file but asp controls in .aspx file. All of my adding records are done by VB coding in .vb file.

Would you mind guide me to start with your method? I hope I don't need to change too much code in aspx file because of this formating issue.

Thanks.

Hi wsee,

In VB,
m is for minute
M is for month

MM => 09
M => 9

so you have to change your DataFormatString to DataFormatString="{0:MM/dd/yyyy}"

Hi Kusno,

Oh yes, upper case makes the difference. Thank you for solving my problem.

wsee

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.