1
Answer

hoiw to bind json data to gridview in c#

hoiw to bind json data to gridview in c# i have this api key only iam geeting json data but how to fill gridview plz
https://api.icarol.com/v1/Resource/Taxonomy?db=2285 
Answers (1)
0
Suresh Kumar

Suresh Kumar

NA 3.1k 36.5k 7y
Hi ,
 
Below code may help
 
 
$.ajax(
{
type: "POST",
url: "Gridview.aspx/BindSearchDatatable",
//data: "{officename : '"+searchtext+"'}",
data: JSON.stringify({ officename: searchtext }),
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (data) {
//iterate the gridview,bind the json data to gridview
$("#gvDetails").empty();
for (var i = 0; i < data.d.length; i++) {
$("#gvDetails").append("" + data.d[i].OfficeName + "" + data.d[i].City + "" + data.d [i].Country + "");
}
},
error: function (x, e) {
alert("The call to the server side failed. " + x.responseText);
}
}