Hello
I've an asp.net gridview "gvCustomers" which displays the list of customers at the same time I want to display the list of (single / multiple) order(s) placed by the respective customer.
My issue is I'm unable to find the gridview "gvItems" placed inside "gvCustomers" using jQuery
Suggestions will be appreciated.
Thanks
What I have tried:
function LoadOrderItems(orderId) {
var row1;
$.ajax({
type: "POST",
url: "manageOrders.aspx/PopulateItems",
data: '{orderId: "' + orderId + '" }',
contentType: "application/json; charset=utf-8",
dataType: "json",
async: "true",
beforeSend: function () {
},
success: function (response) {
var xmlDoc1 = $.parseXML(response.d);
var xml1 = $(xmlDoc1);
var orders1 = xml1.find("dsItems");
var html1 = '<table id="gvItems">';
if (row1 == null) {
row1 = $("#<%=gvItems.ClientID %> tr:last-child").clone(true);
}
$("#<%=gvItems.ClientID %> tr").not($("#<%=gvItems.ClientID %> tr:first-child")).remove();
html1 += $("#<%=gvItems.ClientID %>").html();
if (orders1.length > 0) {
$.each(orders1, function () {
html1 += "<tr>";
$(row1).find("#lblProduct").html($(this).find("prod_name").text());
$("#<%=gvItems.ClientID %>").append(row1);
row1 = $("#<%=gvItems.ClientID %> tr:last-child").clone(true);
html1 += $(row1).html();
html1 += "</tr>";
});
} else {
$("#lblRecordCount").text("");
var empty_row = row1.clone(true);
$("td:first-child", empty_row).attr("colspan", $("td", row1).length);
$("td:first-child", empty_row).attr("align", "center");
$("td:first-child", empty_row).attr("class", "well");
$("td:first-child", empty_row).html("No Data Available");
$("td", empty_row).not($("td:first-child", empty_row)).remove();
$("#<%=gvItems.ClientID %>").append(empty_row);
}
html1 += '</table>';
},
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}