Format Date in Gridview TemplateItem Hyperlink Field VB

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
It seems like Ive looked everywhere and just cannot find the right solution. Im new so please forgive me ahead of time.
Im using Visual Web Dev 2010 Express and have a gridview and SQL 2008 datasource. The column is in the SQL db as a date type and comes in from the stored procedure formatted like yyyy-mm-dd.
I need the navigateurl to be base on a different column in the row and that is working fine.
I need the text to show a date field from the row but I need it formatted like MM/dd/yyyy. Using Eval with format string is not working. It works with other columns in the gridview that are not hyperlinks.
I think I would like to do it in the code behind for use in other scenarios but am open to suggestions for the best approach as I am learning.
<pre class="prettyprint lang-vb <asp:TemplateField HeaderText="FM Date" SortExpression="fmc_date
<ItemTemplate>
<asp:HyperLink ID="HyperLinkFMCDate" runat="server"
NavigateUrl=<%# Eval("proj_id", "DataTracking.aspx?proj={0}") %>
Text=<%# Eval("fmc_date", "{0:d}")%>
ToolTip="Click to get tracking data.
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
[/code]
<br/>

View the full article
 
Back
Top