How can I stop the time from displaying in a GridView when displaying a date?

后端 未结 3 697
南笙
南笙 2021-01-14 22:59

I have a web application that I am working on(ASP.NET 2.0 & C#). In it, I have a gridview that gets data from an Oracle Database. Some of the data that I need to display

3条回答
  •  长发绾君心
    2021-01-14 23:12

    if you set your datasource programmatically (code behind), you can still have all your columns in the gridview (use asp:DataBoundColumn)

    DataFormatString="{0:d}"
    

    EDIT

    this code is for your aspx page, if you really want to stick your presentation logic in your code behind - you have 2 options:

    1. format the Date on "RowDataBound" event
    2. format the Date in your query - that way you won't have to deal with formatting in code at all

提交回复
热议问题