GridView的使用:
1、无法绑定控记录。当GridView去绑定DataSet时,如果DataSet是空记录。则GridView连表头都不显示,感到很郁闷。。。。。。
2、绑定列对于时间的格式好像支持的有错误。
比如我有个时间字段datetime="2005-12-23 10:01:00"
当我的GridView使用绑定列,就无法设置格式。
<asp:BoundField DataField="datetime" DataFormatString="{0:HH:mm}" />
这样,在列中,它还是显示:2005-12-23 10:01:00
如果我使用模板列,却是成功的。
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("datetime", "{0:HH:mm}") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
这样,在列中,它显示:10:01
其中关于Bind的使用, 以及 GridView的DataFormatString的使用.
DataFromatString改为DataFormatString="{0:yyyy-MM-dd} 就可以绑定显示时间了.