指定的转换无效。
来源:百度知道 编辑:UC知道 时间:2024/05/15 03:32:30
“/WebApplication2”应用程序中的服务器错误。
--------------------------------------------------------------------------------
指定的转换无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidCastException: 指定的转换无效。
源错误:
行 80: Session["Power"]=dr["Power"];
行 81: lbl_message.Text="欢迎您!"+Session["ID"];
行 82: if((char)Session["Power"]==2)
行 83: {
行 84: hl_course.Enabled=false;
源文件: c:\inetpub\wwwroot\webapplication2\default.aspx.cs 行: 82
堆栈跟踪:
[InvalidCastException: 指定的转换无效。]
WebApplication2.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication2\default.aspx.cs:82
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEven
--------------------------------------------------------------------------------
指定的转换无效。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.InvalidCastException: 指定的转换无效。
源错误:
行 80: Session["Power"]=dr["Power"];
行 81: lbl_message.Text="欢迎您!"+Session["ID"];
行 82: if((char)Session["Power"]==2)
行 83: {
行 84: hl_course.Enabled=false;
源文件: c:\inetpub\wwwroot\webapplication2\default.aspx.cs 行: 82
堆栈跟踪:
[InvalidCastException: 指定的转换无效。]
WebApplication2.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\webapplication2\default.aspx.cs:82
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEven
Session获取的返回值本来就是String类型的,你在这里直接判断if(Session["Power"] == "2")就可以了,还可以提高程序的性能
Session["Power"]里存储的是什么类型
如果是int
if((int)Session["Power"] == 2)
如果是string
if((string)Session["Power"] == "2")
如果是char
if(((char)Session["Power"])=='2')
只要是值类型:
if(Session["Power"].ToString() == "2")
源文件: c:\inetpub\wwwroot\webapplication2\default.aspx.cs 行: 82 :
if((char)Session["Power"]==2)
换成
if(((char)Session["Power"])=='2')
试试
指定的转换无效。
this.Label1.Text=Convert.ToString(Convert.ToInt32(sdr.GetInt32(2)));指定的转换无效????为什么??
(asp,急)datediff 指定了无效的参数 1
删除文件或文件夹出错:无法删除Chess:指定的文件名无效或太长。请指定另以文件名
电脑蓝屏 0XFE(.......) (指定的延伸属性无效) 应该是内存的问题
Windows Firewall/Internet Connection Sharing (ICS)错误2001 指定的驱动程序无效
重装系统时提示“指定给安装程序的安装源路经无效
蓝屏0X000000FE意思是<指定的延伸属性名称无效>
"为 datediff 指定了无效的参数 1" 急救
100分 天天蓝屏啊 0x00FE 指定的延伸属性名称无效