如上图
以下是搜索按钮的方法
function SearchClgzRecord() {
        var fcsjbegin = Ext.get('fcsj_begin').dom.value;
        var fcsjend = Ext.get('fcsj_end').dom.value;
        var sdzmccx = Ext.get('sdzmc_cx').dom.value;
        var zdzmccx = Ext.get('zdzmc_cx').dom.value;
        var clbhcx = Ext.get('clbh_cx').dom.value;
        clgzRecordStore.reload
        ({
            params: { start: 0, limit: pageSize, fcsj1: fcsjbegin, fcsj2: fcsjend, sdzmc: sdzmccx, zdzmc: zdzmccx, clbh: clbhcx }
        });
    }  这个是正常传值但是按了bbar的刷新按钮的话 就出现 "未将对象引用设置到对象实例"错误
cs接收文件
if (!IsPostBack)
        {
            string starts = Request.Form["start"];
            string limits = Request.Form["limit"];
            string fcsj1 = Request.Form["fcsj1"].ToString();//这行出错了            string fcsj2 = Request.Form["fcsj2"].ToString();
            string sdzmc = Request.Form["sdzmc"];
            string zdzmc = Request.Form["zdzmc"];
            string clbh = Request.Form["clbh"];            if (starts != null && limits != null)
            {
                int start = int.Parse(starts);
                int limit = int.Parse(limits);
                JSON = bll.GetClgzxxInfos(start, limit, fcsj1, fcsj2, clbh, zdzmc);
            }
            else
            {
                Response.Write("{success:'false'}");
            }
        }

解决方案 »

  1.   

    string fcsj1s = Request.Form["fcsj1"].ToString();//这行出错了 
    string fcsj2s = Request.Form["fcsj2"].ToString();
    ...下面的同样问题两样修改
      

  2.   


    string fcsj1 = Request.Form["fcsj1"].ToString();//这行出错了
    string fcsj2 = Request.Form["fcsj2"].ToString();改成这样的//先写一函数,代替Request.Form
    public string RequestForm(string key){
      string val =  Request.Form[key];
      if(val==null) return "";
      return val;
    }
    ...
    string fcsj1 = RequestForm("fcsj1");
    string fcsj2 = RequestForm("fcsj2");//其它类似的地方也做同样修改,否则当你没有传值的时候强行使用.ToString()将报错
    //至于无法取值的原因是你点下边的刷新按钮时,并未给页面传递fcsj1、fcsj2等参数
    ...
      

  3.   


    int start = int.Parse(starts);
    int limit = int.Parse(limits);另外,这类写法,当上面的Request.Form获取的值不能正常转成int型的话,将会发生异常建议放在try{}catch(){}模块中执行,否则先判断字符串是否可以被转换为int类型,可以再转换,否则做其它操作
      

  4.   

    谢谢  luxu001207  问题解决
      

  5.   

    兰州 怎么解决的         int start = int.Parse(Request.Form["start"].ToString());
    也有同样的错误 该怎么解决?