|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
gridview.boundfield.dataformatstring doesn't work<asp:gridview id="gvRDK" runat="server" autogeneratecolumns="false"> <columns> <asp:Boundfield DataField="DateCreate" DataFormatString="DateCreate: {0:d}" HeaderText="Date Created:" /> </columns> </asp:gridview> but i got the following output: Date Created: DateCreate: 1/1/1900 12:00:00 AM why isn't it formatting as a short date? i then tried to following code: <asp:datagrid id="dgRDK" runat="server" autogeneratecolumns="false"> <columns> <asp:Boundcolumn DataField="DateCreate" DataFormatString="DateCreate: {0:d}" HeaderText="BoundColumn" /> </columns> </asp:datagrid> and got the expected output: BoundColumn DateCreate: 1/1/1900 thank you for your help Hi Abraham,
And here comes the solution: http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx Add HtmlEncode="false" to the BoundField and all will work fine. Bernhard Winkler On Wed, 30 Nov 2005 14:14:46 -0500, "Abraham Andres Luna" <a**@rdk.com> wrote: Show quoteHide quote >i tried the following code: > ><asp:gridview id="gvRDK" runat="server" autogeneratecolumns="false"> > <columns> > <asp:Boundfield DataField="DateCreate" DataFormatString="DateCreate: >{0:d}" HeaderText="Date Created:" /> > </columns> ></asp:gridview> > >but i got the following output: > > Date Created: > DateCreate: 1/1/1900 12:00:00 AM > > >why isn't it formatting as a short date? > >i then tried to following code: > ><asp:datagrid id="dgRDK" runat="server" autogeneratecolumns="false"> > <columns> > <asp:Boundcolumn DataField="DateCreate" DataFormatString="DateCreate: >{0:d}" HeaderText="BoundColumn" /> > </columns> ></asp:datagrid> > > >and got the expected output: > BoundColumn > DateCreate: 1/1/1900 > > >thank you for your help >
Checkbox and Javascript
VS2005 DataList with Nested GridView using ObjectDataSource Validators in composite control firing prematurely BoundField and DataFormatString in ASP.NET 2.0 - Bug ? GridView whole row select Custom control that ingerits from textbox Problem with Custom Web Controls in Visual Studio 2005 datagrid pixel height not respected ReadOnly (HTML) controls to stay black and not grey Losing Session Values |
|||||||||||||||||||||||