if (Request.Params["teacherId"] != null)
        {
            //Page.Response.Write("teacherId ="+Request.Params["teacherId"]); 
            nteacherId = Int32.Parse(Request.Params["teacherId"].ToString());
        }总是报错说:输入字符串格式错误!  刚学ASp.net 希望大家多多指教!

解决方案 »

  1.   

    断点调试判断Request.Params["teacherId"]是否为空?不为空 Request.Params["teacherId"].ToString()的值是多少?是否可以转换为整形?
      

  2.   

    看Request.Params["teacherId"]是不是可以转化成Int32  
    最好用Int32.TryParse("");int result=0;
    bool b = Int32.TryParse(Request.Params["teacherId"].ToString(),out result);
    //bool为true,转化成功  否则false
      

  3.   

    Request.Params["teacherId"]  空了。。
    没取到值。
      

  4.   

    断点调试 Request.Params["teacherId"].ToString()  看下是什么值
      

  5.   

    看Request.Params["teacherId"].ToString()的值nteacherId 类型与后面保持一直如果Request.Params["teacherId"].ToString()是正确的。
    Int32.TryParse(Request.Params["teacherId"].ToString(),out result);Int32.TryParse(value,out result);使用
      

  6.   

    谢谢各位的帮组,自己解决啦!(犯了了一个很而的错误,“teacherId”命名冲突的原因,导致值得增多!)