本文介绍了错误:无法转换类型'System.Int32'的对象类型'System.String'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有完美的完成编码注册页面,登录现在UpdateCustomer网页有错误 - 背景信息:我使用的是Microsoft Access作为数据源
LabelState.Text =(字符串)会议[sState]; LabelPostalCode.Text =(字符串)会议[sPostalCode]; LabelContactNumber.Text =(字符串)会议[sContactNumber]; LabelEmail.Text =(字符串)会议[sEmail]; LabelPassword.Text =(字符串)会议[spassword开头];这里
一切都很好,除了 LabelContactNumber.Text =(字符串)会议[ sContactNumber] 。
我相信这是因为只有ContactNumber在访问权限设置为INT其余因此文本有,当我使用没有错误(串)。
解决方案 LabelContactNumber.Text =(会话[sContactNumber]!= NULL)'会话[sContactNumber]的ToString()://的String.Empty或任何默认值你想;
I have finish perfectly coding Register Page, Login and now the UpdateCustomer page has errors - Background info : I'm using Microsoft Access as data source
LabelState.Text = (string)Session["sState"]; LabelPostalCode.Text = (string)Session["sPostalCode"]; LabelContactNumber.Text = (string)Session["sContactNumber"]; LabelEmail.Text = (string)Session["sEmail"]; LabelPassword.Text = (string)Session["sPassword"];Everything here is fine except LabelContactNumber.Text = (string)Session["sContactNumber"].
I believe it is because only ContactNumber in Access is set as Int the rest is Text therefore there's no error when I use (string).
解决方案 LabelContactNumber.Text = (Session["sContactNumber"] != null) ? Session["sContactNumber"].ToString() : string.Empty //or whatever default value your want;
更多推荐
错误:无法转换类型'System.Int32'的对象类型'System.String'
发布评论