4 Replies - 1362 Views - Last Post: 26 March 2014 - 10:03 AM Rate Topic: -----

#1 jonnyp22   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-March 14

Display date in datagrid without timestamp

Posted 26 March 2014 - 09:24 AM

Good Morning All- I'm starting to do a bit more programming at my job lately and figured I would join a forum since i'll most likely come across a lot of questions along the way.. today is that day!

I am developing a simple webform in Visual Studio 2008. I have an Oracle table which I am currently displaying automatically in a GridView. One column is store_num, the second is missing_date. When I view the oracle table, the date is in the format I want, mm/dd/yyy. However, when I populate the GridView using the table, a timestamp is displayed.

I read that this can be edited via the GridView Tasks --> Edit Columns using the DefaultCellStyle setting, but I do not see this option.

Another option I though of was converting the data before being populated to the table, but I am connecting straight to the table and do not wish to import using a custom sql.

Does anyone know of a solution to this issue using Visual Studio 2008? If so, your assistance would be greatly appreciated!

Is This A Good Question/Topic? 0
  • +

Replies To: Display date in datagrid without timestamp

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15557
  • View blog
  • Posts: 62,284
  • Joined: 12-June 08

Re: Display date in datagrid without timestamp

Posted 26 March 2014 - 09:33 AM

What's your code look like for populating the grid from the database?
Was This Post Helpful? 1
  • +
  • -

#3 demausdauth   User is offline

  • D.I.C Addict
  • member icon

Reputation: 190
  • View blog
  • Posts: 693
  • Joined: 03-February 10

Re: Display date in datagrid without timestamp

Posted 26 March 2014 - 09:51 AM

What you want to do is format the data. You can start here.
Was This Post Helpful? 1
  • +
  • -

#4 jonnyp22   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-March 14

Re: Display date in datagrid without timestamp

Posted 26 March 2014 - 09:57 AM

View Postmodi123_1, on 26 March 2014 - 09:33 AM, said:

What's your code look like for populating the grid from the database?


I just have it autogenerating from my data source:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#999999" 
        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
        <Columns>
            <asp:BoundField DataField="ORG_LVL_CHILD" HeaderText="Store Number" 
                SortExpression="ORG_LVL_CHILD" />
            <asp:BoundField DataField="MISSING_SALES_DATE" HeaderText="Missing Sales Date" 
                SortExpression="MISSING_SALES_DATE" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="Gainsboro" />
    </asp:GridView>

Was This Post Helpful? 0
  • +
  • -

#5 jonnyp22   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-March 14

Re: Display date in datagrid without timestamp

Posted 26 March 2014 - 10:03 AM

I've entered
DataFormatString="{0:d}"
as instructed and format is looking good now! Thanks all!

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#999999" 
        BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
        <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
        <Columns>
            <asp:BoundField DataField="ORG_LVL_CHILD" HeaderText="Store Number" 
                SortExpression="ORG_LVL_CHILD" />
            <asp:BoundField DataField="MISSING_SALES_DATE" HeaderText="Missing Sales Date" 
                SortExpression="MISSING_SALES_DATE"
                DataFormatString="{0:d}" />
        </Columns>
        <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
        <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        <AlternatingRowStyle BackColor="Gainsboro" />
    </asp:GridView>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1