Click here to Skip to main content
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 0:59am
Edited 27-Dec-12 1: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 881
1 OriginalGriff 270
2 Volynsky Alex 205
3 CPallini 180
4 Richard Deeming 175
0 OriginalGriff 5,640
1 Sergey Alexandrovich Kryukov 4,693
2 CPallini 4,540
3 George Jonsson 3,132
4 Gihan Liyanage 2,445


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 27 Dec 2012
Copyright © CodeProject, 1999-2014
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