Jquery easyui的DataGrid結合asp.net綁订數據問題
Jquery easyui的DataGrid結合asp.net綁定數據問題
我前臺用了Jquery easyui的DataGrid控件,我知道要伺服器要返回json數據,但是我不知道在WebForm4.aspx怎樣返回json數據
我想在WebForm4.aspx執行動作查詢sql語句 select name,value from userinf 查出來的數據,那我怎樣把它變成json對象返回給前臺的DataGrid控件綁定數據呢
------解决方案--------------------
stringBuider 拼接字符串就OK
json 是键值对
这就是 json
columns: [[
{ field: 'name', title: '名字', width: 100 },
{ field: 'value', title: '年齡', width: 100, align: 'right' }
]]
实际上就是一个字符串
好比xml. 也是字符串。
他们都有自己的规则罢了
- JScript code
$(document).ready(function () { $('#list').datagrid({ title: '查詢結果', iconCls: 'icon-save', width: 800, height: 250, url: "../WebForm4.aspx", columns: [[ { field: 'name', title: '名字', width: 100 }, { field: 'value', title: '年齡', width: 100, align: 'right' } ]], pagination: true, rownumbers: true }); });
我前臺用了Jquery easyui的DataGrid控件,我知道要伺服器要返回json數據,但是我不知道在WebForm4.aspx怎樣返回json數據
我想在WebForm4.aspx執行動作查詢sql語句 select name,value from userinf 查出來的數據,那我怎樣把它變成json對象返回給前臺的DataGrid控件綁定數據呢
------解决方案--------------------
stringBuider 拼接字符串就OK
json 是键值对
这就是 json
columns: [[
{ field: 'name', title: '名字', width: 100 },
{ field: 'value', title: '年齡', width: 100, align: 'right' }
]]
实际上就是一个字符串
好比xml. 也是字符串。
他们都有自己的规则罢了