Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to pass Date Time as querystring, and i have written following code:
C#
string dateTime = Request.QueryString["DateStarted"];
           DateTime dt = Convert.ToDateTime(dateTime);
           Response.Write(dt.ToString());

But i am getting wrong Date. It by default takes DateTime as 1/1/0001 12:00:00 AM.
my actual date is this 08/19/2011 05:55 PM

So how can i get exact value of date.


Thanx
Posted
Comments
Toniyo Jackson 5-Sep-11 5:24am    
How you are passing the query string?

use the below code to send query string:


C#
LinkButton1.PostBackUrl = "~/NavigationPage.aspx?Date=" + DateTime.Now.ToString();


and for retrival :
C#
DateLabel.Text= Request.QueryString["Date"];
 
Share this answer
 
Comments
Dhunky 5-Sep-11 5:21am    
Thanx but i am not using linkbutton as i m fetching date from gridview.
Rahul.KumarSharma 5-Sep-11 7:27am    
But you have not specify this in your question please be clear in your question.

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