HighTechTalks DotNet Forums  

Using a DateTime as a DataKeyField

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss Using a DateTime as a DataKeyField in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Keith Patrick
 
Posts: n/a

Default Using a DateTime as a DataKeyField - 06-06-2006 , 11:02 AM






I have a DataGrid that uses a DateTime coming back from the DB as its
DataKeyField, since that timestamp is the only unique ID I have for the
records I am displaying. The problem is that the DateTime is being stored
down to the second rather than to the millisecond, which ruins the ID. Is
there some way to tell the grid to store that DateTime with millisecond
precision, or at least store the tick count?



Reply With Quote
  #2  
Old   
Ken Cox [Microsoft MVP]
 
Posts: n/a

Default Re: Using a DateTime as a DataKeyField - 06-06-2006 , 11:14 PM






Hi Keith,

Are the milliseconds available in the DateTime? If so you might need to
bind to a custom datetime string to get at them.

I'm thinking of something like this:

<columns>
<asp:templatecolumn>
<itemtemplate>
<asp:label id="Label1" runat="server" text='<%#
format(DataBinder.Eval(Container.DataItem, "DateTime"),"yyyyMMdd:HHmmss%ff")
%>'></asp:label>
</itemtemplate>
</asp:templatecolumn>
</columns>

The ff stuff is discussed here:

http://msdn.microsoft.com/library/de...matstrings.asp

Ken

"Keith Patrick" <richard_keith_patrick (AT) hotmail (DOT) com> wrote

Quote:
I have a DataGrid that uses a DateTime coming back from the DB as its
DataKeyField, since that timestamp is the only unique ID I have for the
records I am displaying. The problem is that the DateTime is being stored
down to the second rather than to the millisecond, which ruins the ID. Is
there some way to tell the grid to store that DateTime with millisecond
precision, or at least store the tick count?




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.