Hi,
I want to access ASP.net Gridview control i.e. bind data into gridview control from static method(ajax webmethod). How can I do this.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Dhanunjay Jajimoggla100 reputationPosted Jun 17, 2014, 5:19 AM EDT
Call the your static method from javascript using pageMethods. bind data to your Gridview in javascript.
function GetData() {
$.ajax({
type: "POST",
url: "Your.aspx/getData",
data: data .
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var Table= xml.find("Table");
var row = $("[id*=Gridview1] tr:last-child").clone(true);
$("[id*=Gridview1] tr").not($("[id*=Gridview1] tr:first-child")).remove();
$.each(Table, function () {
var customer = $(this);
$("td", row).eq(0).html($(this).find("Column1").text());
$("td", row).eq(1).html($(this).find("Column2").text());
$("td", row).eq(2).html($(this).find("Column3").text());
$("[id*=gvCustomers]").append(row);
row = $("[id*=Gridview1] tr:last-child").clone(true);
});
}
gunjan aroraRank #8,160 · 227 reputationPosted Jun 18, 2014, 8:04 PM EDT