kcwallace Posted October 10, 2007 Posted October 10, 2007 I am using the following to generate a field in a gridview. Is there a way to format the data? specifically this is a returned date of 1/1/2007, but it displays the 1/1/2007 12:00. I need to drop the 12:00. THe backend is SQL Server 2005. Do I need to format it there? <asp:TemplateField HeaderText="SD" SortExpression="StartDate"> <ItemTemplate> <asp:Label ID="Label15" runat="server" Text='<%# Bind("startdate") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtStartDate" runat="server" Text='<%# Bind("startdate") %>'></asp:TextBox> </EditItemTemplate> <FooterTemplate> <asp:TextBox ID="txtStartDate" runat="server" Text=""></asp:TextBox> </FooterTemplate> </asp:TemplateField> Quote Go Beavs!!!
Administrators PlausiblyDamp Posted October 10, 2007 Administrators Posted October 10, 2007 You should be able to specify a valid format string as part of the binding expression i.e. '<%# Bind("startdate") %>' 'replace with '<%# Bind("startdate", "d") %>' for a handy list of supported format codes try here Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
kcwallace Posted October 10, 2007 Author Posted October 10, 2007 Thank you <%# Bind("startdate", "{0:d}") %> Worked perfectly Quote Go Beavs!!!
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.