解决方案 »

  1.   

    Request.Params["iserr"];Request.Params["total"];
      

  2.   

    现在是这样:var content = $("#dg").datagrid('getRows');
        $.ajax({
            type: 'POST',
            data: "content="+content,
            url: "../../BasicInfo/ToExcel"
        });
    firebug调试post的效果:content=[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
    .net后台接受:string result=Request.Params["content"];接受不到值?
      

  3.   

    content是个json数组? 那样的话要按里面的属性取值啊,就是2l那样子,除非你把这个json数组变成字符串的形式才能用requet["content"]取值
      

  4.   

    无法直接传对象到后台的,只能拼接一下字符串,把content循环一下iserr=false&total=7&row=xxxxx
      

  5.   


    function JsonToStr(json){
                var strs = [];
                strs.push("{");
                for (var i in json) {
                    strs.push("\"");
                    strs.push(i);
                    strs.push("\"");
                    strs.push(":");
                    strs.push(TypeParse(json[i]));
                    strs.push(",");
                }
                if (strs.length > 1) {
                    strs.pop();
                }
                strs.push("}");
                return strs.join("");
            }        function ArrayToStr(array){
                var strs = [];
                strs.push("[");
                for (var i in array) {
                    strs.push(i);
                    strs.push(",");
                }
                if (strs.length > 1)
                    strs.pop();
                strs.push("]");
            }        function TypeParse(obj){
                if ($.isArray(obj)) {
                    return ArrayToStr(obj)
                } else if ($.isFunction(obj)) {
                    return "{}";
                }  else if ($.isNumeric(obj)) {
                    return obj;
                } else if ((typeof obj) == "string") {
                    return "\""+obj+"\"";
                }else if((typeof obj) == "boolean"){
                    return obj;
                }
                else if ($.isEmptyObject(obj)) {
                    return "\"\"";
                } else if ($.isPlainObject(obj)) {
                    return JsonToStr(obj);
                }
                return "\"\"";
            }能转一些简单的
      

  6.   

     mvc中controller取得前台的datagrid的page和rows的方法:如果你的url: "../../BasicInfo/ToExcel",那么在你的ToExcel方法中以page和rows作为参数传递。例如
     public ActionResult  ToExcel(int? page, int? rows)        {
                page = page == null ? 1 : page;
                rows = rows == null ? 1 : rows;
                ……
            }
    这样应该能获取page和rows的值,我这里是可以的,如果有更好的方法,希望回复。