Click here to Skip to main content
11,487,401 members (71,403 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
i inserted all the record in the database.

i have one button view.when i click that button all record should be displayed in the Grid View.

Grid view Button Query as follows;

sql ="select Name,DOB,Mobileno,Weddingday,Email from BIrthDayWish where Active ='A' ORDER BY Name";
        Dr = SCon.ReadSql(Sql);
        GridView1.DataSource = Dr;
        GridView1.DataBind();
        GridView1.Visible = true;
output in Grid View as follows

Name DOB Mobile no Wedding day Email
ram 22/12/1986 12:00:00 AM 9945598565 22/12/2009 12:00:00 AM ram@gm.com


but i want the output in grid view related to DOB and Wedding day date to be shown as

Name DOB Mobile no Wedding day Email
ram 22/12/1986 9945598565 22/12/2009 ram@gm.com

Not needed a
DOB Wedding Day
12:00:00 AM 12:00:00 AM
sql ="select Name,DOB,Mobileno,Weddingday,Email from BIrthDayWish where Active ='A' 
ORDER BY Name";
from my above query how to correct the query and get the outputvvas follows
Name DOB Mobile no Wedding day Email
ram 22/12/1986 9945598565 22/12/2009 ram@gm.com
Posted 27-Dec-12 1:59am
Edited 27-Dec-12 2:08am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

<asp:BoundField HeaderText="DOB" DataField="DOB"  DataFormatString="{0:dd/MM/yyyy}">

Check following link for more information:
http://www.codedigest.com/Articles/ASPNET/137_How_to_format_DateTime_in_GridView_BoundColumn_and_TemplateColumn.aspx[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try this:
SELECT 
Name, 
CONVERT(varchar, DOB, 103) AS DateOfBirth, 
Mobileno, 
CONVERT(varchar, Weddingday, 103) AS WeddingDay, 
Email 
FROM BIrthDayWish 
WHERE Active ='A' 
ORDER BY Name
  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 9,063
1 OriginalGriff 8,287
2 Sascha Lefèvre 3,334
3 Maciej Los 2,946
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 27 Dec 2012
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