foreach(DataRowView DRV in Dv_Source)
{
t = DRV.Row["realid"].ToString();  // realid=32 and other int type.
         t        += "|" + GetInfoById(System.Int32.Parse(t));
         
}public string GetInfoById(int/*System.Int32 这也试改过了*/ identity)
{
  //todo function.
}错误提示:输入字符串的格式不正确?

解决方案 »

  1.   

    t        += "|" + GetInfoById(System.Int32.Parse(t));
    改成:
     t        += "|" + GetInfoById(Convert.ToInt32(t));
      

  2.   

    如果 t 为空时或不是int类型时就会出现“输入字符串的格式不正确”错误
    要确定 DRV.Row["realid"].ToString()得到的数据可以正确转化为int
      

  3.   

    这个绝对有数据的。没数据不可能从数据库中读出来。
    我也在前面加了: if (t.equals("") || t==null) t=0;
      

  4.   

    foreach(DataRowView DRV in Dv_Source)
    {
    t = DRV.Row["realid"].ToString();  // realid=32 and other int type.
             t        += "|" + GetInfoById(System.Int32.Parse(t)).ToString();
             
    }
      

  5.   

    TO: waikey(人生一笑而过) 
    GetInfoById(int/*System.Int32*/ identity){}