异常详细信息: System.FormatException: 输入字符串的格式不正确。源错误: 行 55:             e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#C0C0FF'");
行 56:             e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
行 57:             e.Row.Cells[8].Text = Convert.ToString(Convert.ToDouble(e.Row.Cells[6].Text.ToString().Trim()) * Convert.ToDouble(e.Row.Cells[7].Text.ToString().Trim()));
行 58:             a += Convert.ToDouble(e.Row.Cells[8].Text.ToString().TrimStart("".ToCharArray()).Trim());
行 59:         }
 红色的代码部分在本机上测试正确,到了服务器上就显示不正确了,不知道是不是代码有问题还是其它的什么原因?请高手解答?

解决方案 »

  1.   

    Cells[7]和Cells[6]转换成double都能成功?
      

  2.   

    Cells[6]或Cells[7]中有空值了可能, 做个调试 用服务器的数据库看看值
      

  3.   

    应该是取来的数据不是Double类型的,避免异常,用TryParse方法。
      

  4.   

    double d6=0;
    double.TryParse(e.Row.Cells[6].Text.ToString().Trim(),out d6);
    double d7=0;
    double.TryParse(e.Row.Cells[7].Text.ToString().Trim(),out d7);
    double d=d6*d7;
    e.Row.Cells[8].Text=d.ToString();
      

  5.   

    可能转成double的时候有NULL值吧,失败的可能性很大..打个断点调试一下了.
      

  6.   

    Cells[6]或Cells[7]中有某个的值是空的,这样conver.todouble()就错了!或者是得到非数字的字符了!