gridview中的日期格式
我修改了根据我的要求掌握详细的 gridview 示例。它工作正常,但其中一个单元格中的日期格式显示为“12/12/2012 12:00:00 AM”。我只想显示“12/12/2012”。请帮忙,代码如下”
<asp:TemplateField HeaderText="Date of Failure" SortExpression="Failure_date" >
<EditItemTemplate>
<asp:TextBox ID="EditFailure_date" runat="server" Columns="20" MaxLength="50" Text='<%# Bind("Failure_date") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="Failure_dateRequiredFieldValidator" runat="server" ControlToValidate="EditFailure_date" Display="Dynamic" ErrorMessage="Can not be blank" SetFocusOnError="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<asp:Label ID="Failure_date" runat="server" Text='<%# Bind("Failure_date") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Possible Duplicate:
Format Date in Bind Statement inside a ListView
I have modified a master detail gridview example as per my requirement. It is working fine but date format in one of cell is displaying as "12/12/2012 12:00:00 AM". I just want to show only "12/12/2012". Please help, code is as below"
<asp:TemplateField HeaderText="Date of Failure" SortExpression="Failure_date" >
<EditItemTemplate>
<asp:TextBox ID="EditFailure_date" runat="server" Columns="20" MaxLength="50" Text='<%# Bind("Failure_date") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="Failure_dateRequiredFieldValidator" runat="server" ControlToValidate="EditFailure_date" Display="Dynamic" ErrorMessage="Can not be blank" SetFocusOnError="True"></asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top" />
<HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" />
<ItemTemplate>
<asp:Label ID="Failure_date" runat="server" Text='<%# Bind("Failure_date") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是您应该使用的格式:
This is the format that you should use:
您可以通过将格式传递给 2 Bind 参数来完成此操作。
You can do it by passing the format to the 2 Bind parameter.