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

后端 未结 3 679
南笙
南笙 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
    0 讨论(0)
  • 2021-01-14 23:18

    You can apply a dataformatstring in the gridview column to only show the date.

    To get it to work you must make sure that HTMLEncode is set to false.

    More information

    0 讨论(0)
  • 2021-01-14 23:31

    You can use DataFormatString="{0:d}" HtmlEncode="False"

    do not forget to use the last section [htmlencode]

    I hope this works ... this works for me !!!!

    Arunendra

    0 讨论(0)
提交回复
热议问题