Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Using a DateTime as a DataKeyField

Reply
Thread Tools

Using a DateTime as a DataKeyField

 
 
Keith Patrick
Guest
Posts: n/a
 
      06-06-2006
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
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      06-07-2006
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" <> wrote in message
news:...
>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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: [2.4.4] creating a datetime.datetime from an XML xs:dateTime skip@pobox.com Python 2 01-06-2009 01:31 PM
[2.4.4] creating a datetime.datetime from an XML xs:dateTime Martin Python 0 12-27-2008 08:08 PM
mx.DateTime to datetime.datetime mp Python 1 07-28-2006 10:57 PM
datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Christos TZOTZIOY Georgiou Python 3 09-13-2003 10:44 AM
RE: datetime: .datetime-.datetime = .timedelta, .time-.time=TypeError ? Tim Peters Python 0 09-09-2003 12:57 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57