Click here to Skip to main content
14,270,121 members
Rate this:
Please Sign up or sign in to vote.
See more:
I want to insert data in a table

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:

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
Rate this:
Please Sign up or sign in to vote.

Solution 1

change the date value to number as like
30/02/2012
30022012
then pass
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hi,

try like below.
// 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.
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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

Pass value like this

Response.Ridirect("confirm.aspx? &tariff_id= " + tariff_id + " &total_price= " + total_price+ " &date= " +date.ToString("dd-mm-yyyy");
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 4

You should encode the datestring. Just replace the "/" with "%2F"
Page 1:
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:
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
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100