Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i have written the following javascript code to search records in grid ,while we are typing in text box(auto search with out button),
if use this script edit button is not displaying in my grid .if i comment this edit update delete is working


<script type="text/javascript">
$(function () {
GetCustomers(1);
});
$("[id*=txtSearch]").live("keyup", function () {
GetCustomers(parseInt(1));
});
$(".Pager .page").live("click", function () {
GetCustomers(parseInt($(this).attr('page')));
});
function SearchTerm() {
return jQuery.trim($("[id*=txtSearch]").val());
};
function GetCustomers(pageIndex) {
$.ajax({
type: "POST",
url: "CS.aspx/GetCustomers",
data: '{searchTerm: "' + SearchTerm() + '", pageIndex: ' + pageIndex + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
}
var row;
function OnSuccess(response) {
var xmlDoc = $.parseXML(response.d);
var xml = $(xmlDoc);
var customers = xml.find("PaymentTracker1");
if (row == null) {
row = $("[id*=GridView1] tr:last-child").clone(true);
}
$("[id*=GridView1] tr").not($("[id*=GridView1] tr:first-child")).remove();
if (customers.length > 0) {
$.each(customers, function () {
var customer = $(this);
$("td", row).eq(0).html($(this).find("Name").text());
$("td", row).eq(1).html($(this).find("ID").text());
$("td", row).eq(2).html($(this).find("InvestmentType").text());
$("td", row).eq(3).html($(this).find("Amount").text());
$("td", row).eq(4).html($(this).find("MonthlyPay").text());
$("td", row).eq(5).html($(this).find("NumberOfMonths").text());
$("td", row).eq(6).html($(this).find("StartDate").text());
$("td", row).eq(7).html($(this).find("EndDate").text());
$("td", row).eq(8).html($(this).find("Phone").text());
$("td", row).eq(9).html($(this).find("Address").text());
$("[id*=GridView1]").append(row);
row = $("[id*=GridView1] tr:last-child").clone(true);
});
var pager = xml.find("Pager");
$(".Pager").ASPSnippets_Pager({
ActiveCssClass: "current",
PagerCssClass: "pager",
PageIndex: parseInt(pager.find("PageIndex").text()),
PageSize: parseInt(pager.find("PageSize").text()),
RecordCount: parseInt(pager.find("RecordCount").text())
});

$(".Name").each(function () {
var searchPattern = new RegExp('(' + SearchTerm() + ')', 'ig');
$(this).html($(this).text().replace(searchPattern, "" + SearchTerm() + ""));
});
} else {
var empty_row = row.clone(true);
$("td:first-child", empty_row).attr("colspan", $("td", row).length);
$("td:first-child", empty_row).attr("align", "center");
$("td:first-child", empty_row).html("No records found for the search criteria.");
$("td", empty_row).not($("td:first-child", empty_row)).remove();
$("[id*=GridView1]").append(empty_row);
}
};
</script>







please help me sir
Posted
Updated 13-Aug-15 20:22pm
v2
Comments
ZurdoDev 12-Aug-15 7:28am    
We can't help you because you dumped a ton of code and didn't even format it. It's too much for someone to try and read through and figure out what is wrong especially when we don't know what it happening.

Please debug your code, narrow down the problem, edit your question and only post the relevant code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900