如何将日期值传递给另一个页面? [英] How can I pass the date value to another page?

查看:102
本文介绍了如何将日期值传递给另一个页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在表格中插入数据



I want to insert data in a table

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





其中reserve_id是auto_id。此外,tariff_id来自表fare_tariff和来自表customer的customer_id。我从reservation.aspx页面中的日历选择中检索了来自数据库的tariff_id,total_price和日期值,然后将其传递给confirm.aspx页面。我想在registration.aspx页面的末尾执行我的查询。所以我想在registration.aspx页面中传递这三个值。现在我的问题是,我成功地将tariff_id和total_price传递给confirm.aspx页面。但我无法以相同的方式传递日期值。在我使用的预订页面中:





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);





我可以在confirm.aspx页面中检索tariff_id和total_price,但是无法检索日期值,此处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?

推荐答案

将日期值更改为数字

30/02/2012

30022012

然后通过
change the date value to number as like
30/02/2012
30022012
then pass






尝试如下。

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()));





参考下面的MSDN文章。

HttpServerUtility.UrlEncode方法(字符串) [ ^ ]

HttpServerUtility.UrlDecode方法(字符串) [ ^ ]



希望它有所帮助。



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

hope it helps.


传递这样的值



Pass value like this

Response.Ridirect("confirm.aspx? &tariff_id= " + tariff_id + " &total_price= " + total_price+ " &date= " +date.ToString("dd-mm-yyyy");


这篇关于如何将日期值传递给另一个页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆