日期:2014-05-16  浏览次数:20470 次

求教easyUI怎么获取MVC后台生成的数据
这是后台的数据

 public ActionResult ResidentInfo() 
        {
            StringBuilder JsonString = new StringBuilder();
            JsonString.Append("{\"total\":10,\"rows\":");
            JsonString.Append("[");
            //for (int i = 0; i < rTB.Rows.Count; i++)
            for (int i = 0; i < 10;i++ )
            {
                JsonString.Append("{");
                JsonString.Append("\"residentID\":\"这是用
户ID\",\"ResidnetName\":\"这是名字\"");

                JsonString.Append("}");
                if(i<9)
                JsonString.Append(",");
            }
            JsonString.Append("]}");


                return Content(JsonString.ToString(),"Application/json");
        }



这是前台代码:
    $('#MeteringTable').datagrid({
        url: '/Query/ResidentInfo',
        columns: [[
                    { field: 'productid', title: '用户ID', width: 200 },
                    { field: 'productname', title: '用户名', width: 200 }
                    ]]
    });

怎么都获取不到数据,请教该如何从后台控制中获取数据
MVC easyui ASP.NET DataGrid

------解决方案--------------------
后台 control 这样写  
public string ResidentInfo()
        {
            返回json串 注意这里拼接的格式,去easyui 官网上面看他json串的格式进行拼装,这里很容易拼错的。
        }
不要写在你的默认的&nb