上传文件时,在正确的格式错误中找不到输入字符串

时间:2013-11-06 20:09:34

标签: c# asp.net input syntax-error

我试图在使用ASP.NET构建的网站中获取上传功能。但它一直让我犯这个错误 '/'应用程序中的服务器错误。

输入字符串的格式不正确。

描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息: System.FormatException:输入字符串的格式不正确。

来源错误:

Line 43:lblDescription.Text = "Problem Description:";
Line 44:txtDescription.Text = dr["problem_desc"].ToString();
Line 45:this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt16(dr["problem"].ToString()));
Line 46:break;
Line 47:case "2": //Alter

源文件: C:\ eteam \ eteam.net - on \ eteamuno \ module_edit.aspx.cs第45行

堆栈追踪:

[FormatException: Input string was not in a correct format.]
   System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +12639413
   System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +224
   System.Int16.Parse(String s, NumberStyles style, NumberFormatInfo info) +41
   eteamuno.module_edit.editvalue() in C:\eteam\eteam.net - on\eteamuno\module_edit.aspx.cs:45
   eteamuno.module_edit.Page_Load(Object sender, EventArgs e) in C:\eteam\eteam.net - on\eteamuno\module_edit.aspx.cs:24
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

将数字字符串转换为数字时,而不是调用Int16调用Int32作为Int16是短暂的。

  

Convert.ToInt32() - >将字符串数字转换为整数。

替换为:

this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt16(dr["problem"].ToString()));

以下:

this.lblFileName.Text = dal.GetFileName(ConstClass.ConnOLEDB, Convert.ToInt32(dr["problem"].ToString()));
相关问题