Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Format Date 1

Status
Not open for further replies.

robertfah

Programmer
Mar 20, 2006
380
US
I've got a datagrid that shows a date (returned from SQL) and I don't want the time to show, just the date. can anyone tell me how I can do this?

Code:
<asp:BoundField DataField="RequestDate" SortExpression="RequestDate" HeaderText="Date">
  <ItemStyle VerticalAlign="top" Width="8%" />
</asp:BoundField>
 
I've done it on the server side like this:
Code:
        Dim field As WebControls.BoundField

        field = New WebControls.BoundField
        field.DataField = "MyDate"
        field.SortExpression = "MyDate"
        field.HeaderText = "My Date"
        [b]field.HtmlEncode = "false"
        field.DataFormatString = "{0:MM/dd/yy}"[/b]
        field.ItemStyle.HorizontalAlign = HorizontalAlign.Left
        GridView.Columns.Add(field)

* Sine scientia ars nihil est
* Respondeat superior
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top