Tengo una plantilla archivada como se indica a continuación. Necesito mostrar la parte de milisegundos de DateTime también.
He leído sobre el dateValue.ToString("fff")
en http://msdn.microsoft.com/en-us/library/bb882581.aspx How to: Display Milliseconds in Date and Time Values
.
¿Cuál es la mejor manera de mostrarlo en el campo de plantilla con Eval?
CÓDIGO
<asp:Literal ID="ltlTime" runat="server" Text='' > <asp:HiddenField ID="hdnMilliSeconds" runat="server" Value='' />
Referencia:
Prueba esto
< %# Convert.ToDateTime(Eval("LastChangeTime")).ToString("FFF") %>
utilizar
select convert(varchar, your_date_field, 121) as LastChangeTime
en su consulta SQL. y luego acceder a “LastChangeTime” en eval
Gracias a @kj siesta. Me lo imaginé. Para el beneficio de los demás lo publicaré aquí:
Utilicé el siguiente
'< %# ((DateTime)Eval("LastChangeTime")).ToString("MM/dd/yyyy hh:mm:ss.fff tt") %>'
CÓDIGO
CÓDIGO DETRÁS
protected void Application_RowCommand(Object sender, CommandEventArgs e) { if (e != null) { int rowIndex = Convert.ToInt32(e.CommandArgument, CultureInfo.InvariantCulture); string applicationID = (((System.Web.UI.WebControls.Literal)grdApplications.Rows[rowIndex].Cells[1].Controls[1]).Text).Trim(); string lastChangeTimeString = (((System.Web.UI.WebControls.HiddenField)grdApplications.Rows[rowIndex].Cells[1].Controls[3]).Value).Trim(); DateTime lastChangeTime = Convert.ToDateTime(lastChangeTimeString); } }