Hi Steve,
Thanks for your posting. As for the displaying DateTime value in DataGRid
column according to its Ticks value question you mentioned, I think we
should use a Template Columns instead of the simple BoundColumn. Are you
currently using BoundColunn to display data? The BoundColumn only simpley
display the certain field retrieved from the datasource via field name and
we can do some additional simple formatting. If you have some more complex
code logical to display the data value, I think it's quite easy to use the
Template Column in which we can use databind statement to embeded our
custom defined helper functions. For exmple:
the following datagrid use a Template Column to display a dateTime field
and use a helper function in the codebehind page class to format the output
according to the dateTime value's Ticks:
<asp
ataGrid id="DataGrid1" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<%# GetFormattedTime((DateTime)DataBinder.Eval(Container.DataItem,
"date")) %>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
ataGrid>
protected string GetFormattedTime(DateTime date)
{
if(date.Ticks == 0)
{
return "Empty Time";
}
return date.ToShortTimeString();
}
And here is a certain tech article introduce the Templates in asp.net :
#Understanding Templates in ASP.NET
http://msdn.microsoft.com/msdnmag/issues/02/01/cutting/default.aspx
Hope also helps. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)