Show Hide Button and Label in GridView cell based on status column using C# that uses jquery paging not working
My code
<script type="text/javascript">
$(function () {
GetCustomers(1);
});
$(document).on("click", '.Pager .page', function () {
GetCustomers(parseInt($(this).attr('page')));
});
$(document).on('click', '.view', function () {
$('[id*=hfId]').val($(this).closest('tr').find('td').eq(0).html());
});
var i = 0;
function GetCustomers(pageIndex) {
$.ajax({
type: "POST",
url: "StockList.aspx/GetCustomers",
data: '{pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
$('[id$=gvDetails]').prepend($("<thead></thead>").append($('[id$=gvDetails]').find("tr:first"))).DataTable().destroy();
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("stocktracking");
var row = $("[id$=gvDetails] tbody tr:last-child").eq(0).clone(true);
$("[id$=gvDetails] tbody tr").not($("[id$=gvDetails] tbody tr:first-child")).remove();
$.each(customers, function () {
$("td", row).eq(0).html($(this).find("no").text());
$("td", row).eq(1).html($(this).find("packinglist").text());
if ($(this).find("type").text().toUpperCase() == "3") {
$("td", row).eq(2).html("Cylinder");
} else {
$("td", row).eq(2).html($(this).find("type").text());
}
$("td", row).eq(3).html($(this).find("location ").text());
$("td", row).eq(4).html($(this).find("datesent").text());
$("td", row).eq(5).html($(this).find("datereceived").text());
$("td", row).eq(6).html($(this).find("waybillno").text());
if ($(this).find("status").text().toUpperCase() == "2") {
$("td", row).eq(7).html("Received");
}
else if ($(this).find("status").text().toUpperCase() == "1") {
$("td", row).eq(7).html("Sent");
}
else if ($(this).find("status").text().toUpperCase() == "1") {
$("td", row).eq(7).html("Sent");
}
else {
$("td", row).eq(7).html($(this).find("status").text());
}
if ($(this).find("status").text().toUpperCase() == "2")
{
$("td", row).eq(8).html( Label1.Visible = true);
$("td", row).eq(8).html(lbl.Visible = false);
$("td", row).eq(8).html(btn.Visible = false);
}
else if ($(this).find("status").text().toUpperCase() == "1")
{
$("td", row).eq(8).html(Label1.Visible = true);
$("td", row).eq(8).html( lbl.Visible = true;);
$("td", row).eq(8).html(btn.Visible = false;);
}
else if ($(this).find("status").text().toUpperCase() == "0")
{
$("td", row).eq(8).html(Label1.Visible = false);
$("td", row).eq(8).html( lbl.Visible = false);
$("td", row).eq(8).html( btn.Visible = true);
}
else {
$("td", row).eq(8).html($(this).find("status").text());
}
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblCompleted" Text="Sent" runat="server" />
<asp:Label ID="Label1" Text="Received Back" runat="server" />
<asp:Button ID="btnPending" Text="Send Out" runat="server" />
</ItemTemplate>
</asp:TemplateField>