【发布时间】:2016-07-19 07:42:04
【问题描述】:
Im need to showing json data in asp.net's gridview (not html table) . I search a lot but i cant figure it out. I got code like this.
function BindGridView() {
//Tabloyu oluşturma
$.ajax(
{
type: "GET",
url: 'http://jsonplaceholder.typicode.com/users',
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function (data) {
for (var i = 0; i < data.length; i++) {
$(".mainGridView").empty();
$(".mainGridView").append('<tr><td class="' + i + '">' + data[i].name + '</td>'
+ '<td>' + data[i].username + '</td></tr>');
};
},
error: function (msg) {
alert(msg.responseText);
}
})
};
<body onload="BindGridView();">
<form id="form1" runat="server">
<div>
<asp:GridView class="mainGridView" runat="server" />
here it s style codes
</asp:GridView>
</div>
</form>
我尝试在 html 表中显示 json 数据,它的工作逻辑相同,但在这种情况下并没有帮助我。 当我运行此代码时,它在控制台屏幕上没有给我任何错误,并且它在浏览器上什么也没有显示它是干净的页面。
【问题讨论】:
标签: jquery asp.net json datagridview