错误:无法转换类型'System.Int32'的对象类型'System.String'

编程入门 行业动态 更新时间:2024-10-27 18:29:20
本文介绍了错误:无法转换类型'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'

本文发布于:2023-05-31 12:01:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/391368.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:类型   对象   错误   System   String

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!