时间的显示问题
第一种 在显示中替换,在HTML中表格中去掉时间
e.Item.Cells[4].Text=e.Item.Cells[4].Text.Split(new char[]{' '})[0].Trim();
第二种 在DataTable中去掉
第三种 在存储过程中去掉
经过多次调试,发现在GridView里设置日期字段格式有两种方法,分别适应于不同的情况。大多数情况下我们可以对日期字段设置dataformatstring="{0:yyyy-MM-dd}",同时需要将htmlencode的属性设置成false,但如果我们使用的是模版列的话就会发现这也不起作用了!那么应该怎么办呢,具体方法如下:
e.Item.Cells[4].Text=e.Item.Cells[4].Text.Split(new char[]{' '})[0].Trim();
第二种 在DataTable中去掉
第三种 在存储过程中去掉
经过多次调试,发现在GridView里设置日期字段格式有两种方法,分别适应于不同的情况。大多数情况下我们可以对日期字段设置dataformatstring="{0:yyyy-MM-dd}",同时需要将htmlencode的属性设置成false,但如果我们使用的是模版列的话就会发现这也不起作用了!那么应该怎么办呢,具体方法如下:
<asp:TemplateField HeaderText="日期时间" SortExpression="DB1_1">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DB1_1", "{0:yyyy-M-d}") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("DB1_1", "{0:yyyy-M-d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DB1_1", "{0:yyyy-M-d}") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("DB1_1", "{0:yyyy-M-d}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
浙公网安备 33010602011771号