Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 7th, 2007, 04:17 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default it's urgent

Hi all,

I have a datetime field in my database.I am showing the values of the table in datagrid in asp.net2.0.now the value displayed is date with time.But i want only the date should be displayed in d grid.So can anyone give me a quick reply in half an hour?
:)

  #2 (permalink)  
Old August 7th, 2007, 04:57 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

Write following code in DataGrid_ItemDataBound event:

DateTime dt = Convert.ToDateTime(e.Item.Cells[5].Text);
string smallDate = dt.ToShortDateString();
e.Item.Cells[5].Text = smallDate;

Cheers!
  #3 (permalink)  
Old August 7th, 2007, 05:12 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

actually my datatype is in smalldatetime.so can u plz giv a quick reply to it?


  #4 (permalink)  
Old August 7th, 2007, 07:40 AM
Friend of Wrox
 
Join Date: Feb 2006
Location: noida, UP, India.
Posts: 133
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to gaurav_jain2403
Default

No problem. The above code will work with smalldatetime(database type) also.


Similar Threads
Thread Thread Starter Forum Replies Last Post
urgent deb_kareng ASP.NET 2.0 Professional 1 August 13th, 2007 07:29 AM
urgent help yash_coolbuddy_forindia BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 1 May 7th, 2007 08:40 AM
urgent help wilsonxue C# 1 July 12th, 2006 06:05 PM
urgent???????????? nsr35 Beginning VB 6 1 October 3rd, 2005 10:57 AM
urgent ??????????????? nsr35 Pro VB Databases 0 October 3rd, 2005 04:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.