Click here to Skip to main content
15,868,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to insert data in a table

SQL
flight_reservation(reserve_id, customer_id, tariff_id, total_price, date)


Where reserve_id is an auto_id. Moreover tariff_id is from table fare_tariff and customer_id from table customer. I retrieved the tariff_id, total_price from database and date value from calender selection in reservation.aspx page, then passed it to confirm.aspx page. I want to execute my query in the end of registration.aspx page. So that I want to pass this three value in registration.aspx page. Now my problem is that, I successfully could pass the tariff_id and total_price to confirm.aspx page. But I couldn't pass the date value in the same manner.. In reservation page I used:

C#
Response.Ridirect("confirm.aspx? &tariff_id= " + tariff_id + " &total_price= " + total_price+ " &date= " +date);


I could retrieve tariff_id and total_price in confirm.aspx page, but the date value couldn't retrieved, Here date is a variable which keep the string value selected from a calender control. Can anyone help me to retrieve the date value?
Posted

change the date value to number as like
30/02/2012
30022012
then pass
 
Share this answer
 
Hi,

try like below.
C#
// Encode the date value using URL Encode.
Response.Ridirect("confirm.aspx? &tariff_id= " + tariff_id + " &total_price= " + total_price+ " &date= " +Server.UrlEncode(date.ToString()));

while retrieving Decode the value like below.
C#
DateTime date = Convert.ToDateTime(Server.UrlDecode(Request.QueryString["date"].ToString()));


refer below MSDN articles.
HttpServerUtility.UrlEncode Method (String)[^]
HttpServerUtility.UrlDecode Method (String)[^]

hope it helps.
 
Share this answer
 
Pass value like this

C#
Response.Ridirect("confirm.aspx? &tariff_id= " + tariff_id + " &total_price= " + total_price+ " &date= " +date.ToString("dd-mm-yyyy");
 
Share this answer
 
v2
You should encode the datestring. Just replace the "/" with "%2F"
Page 1:
C#
string s = date.ToString();//Suppose date is "04/06/2013"
s = s.Replace("/", "%2F");
Response.Ridirect("confirm.aspx? &tariff_id= " + tariff_id + " &total_price= " + total_price+ " &date= " +s);

Page 2:
C#
string s = Request.QueryString["date"];
s = s.Replace("%2F", "/");
DateTime dt;
DateTime.TryParse(s, out dt);//Now dt is your datetime here

and vice versa when you read the string to build your SQL query.


--Amit
 
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