Input string was not in a correct format. 一个老生长塘的问题,大家帮忙看看

狼里格东 2010-01-12 02:48:02
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.


Source Error:


Line 2131: protected void gvCurrentEnrolment_RowDataBound(object sender, GridViewRowEventArgs e)
Line 2132: {
Line 2133: if (e.Row.RowType == DataControlRowType.DataRow)Line 2134: {
Line 2135: if (Convert.ToDecimal(((Label)e.Row.FindControl("lblPaymentStatus")).Text) <= 0)


Source File: C:\Visual Studio Projects\YWCA\ESMD.BO\Member\Edit.aspx.cs Line: 2133


以下是代码:


protected void gvCurrentEnrolment_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Convert.ToDecimal(((Label)e.Row.FindControl("lblPaymentStatus")).Text) <= 0)
{
((Label)e.Row.FindControl("lblPaymentStatus")).Text = "Fully Paid<br/>(Total Paid: $" + Convert.ToDecimal(((Label)e.Row.FindControl("lblPaid")).Text) + ")";
}
else
{
((Label)e.Row.FindControl("lblPaymentStatus")).Text = "Awaiting Payment<br/>(Outstanding : $" + ((Label)e.Row.FindControl("lblPaymentStatus")).Text + ")";
}

if (Roles.IsUserInRole(Membership.GetUser().UserName, "staff_manager") && ((Label)e.Row.FindControl("lblEnrolmentStatus")).Text == "Enrolled")
{
((ImageButton)e.Row.FindControl("imgbtnTransfer")).Visible = true;
}
}
}
...全文
179 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
狼里格东 2010-01-14
  • 打赏
  • 举报
回复
最新进展...

String 转换成 datetime 有错。
郁闷的是,用debug模式找了很久都没找到,其他的用户照常登录,而唯独一个用户出现这个问题。杯具~
狼里格东 2010-01-12
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 wgy2750 的回复:]

假如一个系统,查找其中一个学生,输入学号12345,成功进入edit修改页面。
当我输入另外一个,123457,就抛出上面的错误和提示了。
[/Quote]

这个,补充点,学号都是规定长度。

假如第一个学生的是12345
那么第二个学生的是12347
狼里格东 2010-01-12
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 alifriend 的回复:]
看你标题不就知道了

看你代码,肯定是Convert.ToDecimal里面的东西有错
[/Quote]

[Quote=引用 5 楼 jin20000 的回复:]
嗯,比如空字符之类的东西?
[/Quote]


哎,检查过了,没怎么发现啊。准确来说,
假如一个系统,查找其中一个学生,输入学号12345,成功进入edit修改页面。
当我输入另外一个,123457,就抛出上面的错误和提示了。
jin20000 2010-01-12
  • 打赏
  • 举报
回复
嗯,比如空字符之类的东西?
波导终结者 2010-01-12
  • 打赏
  • 举报
回复
看你标题不就知道了

看你代码,肯定是Convert.ToDecimal里面的东西有错
平生我自如 2010-01-12
  • 打赏
  • 举报
回复
看不出来……
狼里格东 2010-01-12
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 alifriend 的回复:]
你输入的数据不合法呗,比如一个int型的,你给他灌abcdefg进去,肯定不行
[/Quote]

牛牛,在我的代码中可看出是哪个位置?

难道我迷糊了眼睛?看不出了。。。
波导终结者 2010-01-12
  • 打赏
  • 举报
回复
你输入的数据不合法呗,比如一个int型的,你给他灌abcdefg进去,肯定不行

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧