table 后台取数据 方法

提问 已结
12 240
angelsh
angelsh 2018-8-3
悬赏:20飞吻
版本:layui 浏览器:
前端就是看不到数据,问题出在哪儿?


Search_wlb.aspx.cs 后台页面
[WebMethod]
public void GetAllUser()
{

List<ms_wlbModel> datas = MSUpLoadSQL.wlb_list("", "");
EntityDataCreate data = new EntityDataCreate(datas);
//生成json数据
string stuJson = JsonConvert.SerializeObject(data);
Context.Response.Write(stuJson);
}

[WebMethod]
public static string getwlb()//这个方法确定有取到数据
{
List<ms_wlbModel> datas = MSUpLoadSQL.wlb_list("", "");
EntityDataCreate data = new EntityDataCreate(datas);
//生成json数据
string stuJson = JsonConvert.SerializeObject(data);
return stuJson;
}
回帖
  • Yuxi
    2018-8-3
    public class OutLayuiTableVO
    {
    public int code { get; set; }
    public string msg { get; set; }
    public Int64? count { get; set; }
    public object data { get; set; }
    }
    0 回复
  • Yuxi
    2018-8-3
    JSON 格式一致吗?
    0 回复
  • angelsh
    2018-8-3
    忘记截图了,json格式里有/ 感觉不完全一样
    0 回复
  • angelsh
    2018-8-3
    @Yuxi 但是我断点测试你走不到后台的GetAllUser()的方法!不过如果我前端改用ajax取后台数据倒是能走到getwlb()的方法,能看到json数据。
    0 回复
  • Yuxi
    2018-8-3
    最后出JSON的时候按照这个格式,没有数据感觉跟JSON格式有关
    0 回复
  • Yuxi
    2018-8-3
    把POST改成GET 试一下能不能走断点
    0 回复
  • plamo
    2018-8-3
    我借帖子吐槽一下。
    不可否认,返回值的前面带:{
    "code": 0,
    "msg": "",
    "count": 1000,
    "data": [
    是一种很好的思想。但是。。。。我想,大部分人的返回值,都是标准的下面这种格式吧:

    {
    [
    {
    "id": 10000,
    "username": "user-0",
    "sex": "女",
    "city": "城市-0",
    "sign": "签名-0",
    "experience": 255,
    "logins": 24,
    "wealth": 82830700,
    "classify": "作家",
    "score": 57
    },
    {
    "id": 10001,
    "username": "user-1",
    "sex": "男",
    "city": "城市-1",
    "sign": "签名-1",
    "experience": 884,
    "logins": 58,
    "wealth": 64928690,
    "classify": "词人",
    "score": 27
    },
    {
    "id": 10002,
    "username": "user-2",
    "sex": "女",
    "city": "城市-2",
    "sign": "签名-2",
    "experience": 650,
    "logins": 77,
    "wealth": 6298078,
    "classify": "酱油",
    "score": 31
    },
    {
    "id": 10003,
    "username": "user-3",
    "sex": "女",
    "city": "城市-3",
    "sign": "签名-3",
    "experience": 362,
    "logins": 157,
    "wealth": 37117017,
    "classify": "诗人",
    "score": 68
    },
    {
    "id": 10004,
    "username": "user-4",
    "sex": "男",
    "city": "城市-4",
    "sign": "签名-4",
    "experience": 807,
    "logins": 51,
    "wealth": 76263262,
    "classify": "作家",
    "score": 6
    },
    {
    "id": 10005,
    "username": "user-5",
    "sex": "女",
    "city": "城市-5",
    "sign": "签名-5",
    "experience": 173,
    "logins": 68,
    "wealth": 60344147,
    "classify": "作家",
    "score": 87
    },
    {
    "id": 10006,
    "username": "user-6",
    "sex": "女",
    "city": "城市-6",
    "sign": "签名-6",
    "experience": 982,
    "logins": 37,
    "wealth": 57768166,
    "classify": "作家",
    "score": 34
    },
    {
    "id": 10007,
    "username": "user-7",
    "sex": "男",
    "city": "城市-7",
    "sign": "签名-7",
    "experience": 727,
    "logins": 150,
    "wealth": 82030578,
    "classify": "作家",
    "score": 28
    },
    {
    "id": 10008,
    "username": "user-8",
    "sex": "男",
    "city": "城市-8",
    "sign": "签名-8",
    "experience": 951,
    "logins": 133,
    "wealth": 16503371,
    "classify": "词人",
    "score": 14
    },
    {
    "id": 10009,
    "username": "user-9",
    "sex": "女",
    "city": "城市-9",
    "sign": "签名-9",
    "experience": 484,
    "logins": 25,
    "wealth": 86801934,
    "classify": "词人",
    "score": 75
    }
    ]

    我想问问,能够设计表格直接读取这种格式的数据么?
    谢谢了。我是小白。
    0 回复
  • 前面的 是为了 分页,等各种的 数据返回 ,很方便。
    0 回复
  • @plamo 前面的 是为了 分页,等各种的 数据返回 ,很方便。
    0 回复
  • plamo
    2018-8-4
    @亲嘴的奶瓶 如果我前台获得的是data里面的值,那我该如何处理呢?求解。
    0 回复
  • 处理啥 直接付上 ,
    0 回复
  • angelsh
    2018-8-6
    @Yuxi 数据已读出 谢谢!
    方法如下链接但是有新问题:
    http://fly.layui.com/jie/31518/
    0 回复