Bind Gridview using AJAX
http://www.codeproject.com/Tips/775585/Bind-Gridview-using-AJAX
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"
type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
BindGridView();
});
function BindGridView() {
$.ajax({
type: "POST",
url: "Index.aspx/GetData",
contentType: "application/json;charset=utf-8",
data: {},
dataType: "json",
success: function (data) {
$("#grdDemo").empty();
if (data.d.length > 0) {
$("#grdDemo").append("<tr><th>Username</th>
<th>Firstname</th> <th>Lastname</th>
<th>EmailID</th></tr>");
for (var i = 0; i < data.d.length; i++) {
$("#grdDemo").append("<tr><td>" +
data.d[i].Firstname + "</td> <td>" +
data.d[i].Lastname + "</td> <td>" +
data.d[i].Username + "</td> <td>" +
data.d[i].EmailID + "</td></tr>");
}
}
},
error: function (result) {
//alert("Error login");
}
});
}
</script>
</head>
<body>
<form id="frm1" runat="server">
<asp:GridView ID="grdDemo" runat="server">
</asp:GridView>
</form>
</body>
</html>
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。