插入formview和查询字符串 [英] inserting in formview and querystring
问题描述
大家好,
我的电脑日期设置是dd / mm / yyyy,我的asp.net应用程序在按日期搜索或插入或更新时工作正常。
但当我将我的网站上传到我的主机时,其日期格式为mm / dd / yyyy。
我的所有作品都被销毁,因为例如我无法插入19/08/2015这会导致错误甚至是查询字符串
例如mypage.aspx? Date = 19/08/2015也会导致错误。我如何进行插入(19/08/2015)并按日期工作选择?
i想要将19/08/2015插入到我的表中导致错误在formview
谢谢
hi all,
my PC date settings is dd/mm/yyyy and my asp.net application is working fine regarding searching by date or inserting or updating.
but when i uploaded my website to my host which its date format is mm/dd/yyyy.
all my works destroyed because for example i can't insert 19/08/2015 which will cause error or even in querystring
for example "mypage.aspx?Date=19/08/2015" will cause error too. how can i make the inserting(19/08/2015) and selecting by date working ??
i want to insert 19/08/2015 to my table which causes error in formview
thanks
推荐答案
始终使用明确的,非模糊的格式。所以,而不是添加你的日期格式;
Always use explicit, non-ambiguous formats. So rather than adding your Date param like;
& "Date=" & dt.ToString()
使用特定格式
use a specific format
& "Date=" & dt.ToString("yyyy-MM-dd")
当您从查询字符串中读取参数时,将其从该格式转换为
When you read the param from the querystring convert it from that format
DateTime dt;
DateTime.TryParseExact(Request.QueryString["Date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt);
这篇关于插入formview和查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!