Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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;

C#
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
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
Updated 27-Dec-12 1:08am
v2

XML
<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[^]
 
Share this answer
 
Try this:
SQL
SELECT 
Name, 
CONVERT(varchar, DOB, 103) AS DateOfBirth, 
Mobileno, 
CONVERT(varchar, Weddingday, 103) AS WeddingDay, 
Email 
FROM BIrthDayWish 
WHERE Active ='A' 
ORDER BY Name
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900