Click here to Skip to main content
11,479,170 members (45,521 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm
I have been facing problem while upload data from excel file to datagrid view.
Excel contain column's as

name
contact no
address
father's name
from place
to place
time
date
when ever data get load in datagrid view the time column shows data like "30-12-1899 PM 12:20:00"

but actual data is PM 12:20:00 and i dont why this date "30-12-1899" is came up time????

Help me to sort out this problem???
Posted 30-Apr-13 20:25pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I suspect the database that you use to load your gridview have a datatype datetime for time field .If so,get only part from the time field in gridview that you want in your excel.

<asp:BoundField DataField="date1" HeaderText="Date Of Leave" SortExpression="date"
                            DataFormatString="{0:dd/MM/yy}" />

DataFormatString examples:
{0:dd MMMM yyyy} - gives 24 February 2006
{0:MMM dd}-gives Feb 24 (substitue MMM with MMMM for the full month name instead of abbreviation)
{0:dd/MM/yy}-gives 24/02/06
{0:dd/MM/yyyy}-gives 24/02/2006

You can have look at this link for further reference on how to use dataformatstrings.
  Permalink  
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Change ur Date and time column format in Excel

Examble
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 215
1 OriginalGriff 205
2 F-ES Sitecore 185
3 Frankie-C 120
4 DamithSL 85
0 Sergey Alexandrovich Kryukov 7,890
1 OriginalGriff 7,441
2 Sascha Lefèvre 3,064
3 Maciej Los 2,491
4 Richard Deeming 2,335


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 1 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100