Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Frnds,

I have a Gridview and Textbox to Search the Records.

I got jQuery code for Search the Records. So where to add this Code in my asp.net application.

Please suggest me.

Thanks,
Posted

XML
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("p").click(function(){
$(this).hide();
});
});
</script>
</head>

<body>
<p>If you click on me, I will disappear.</p>
</body>

</html>


check this link
http://www.w3schools.com/jquery/default.asp[^]
 
Share this answer
 
first you add/download jquery
then in your aspx page
XML
<script src="jqueery.min.js" type="text/javascript"></script>
<script type='text/javascript'>
 
Share this answer
 
Comments
Ranjith Reddy CSE 9-May-12 2:59am    
This is My code for Search, where to add this in asp.net appl.


//Code Starts
$(document).ready(function() {

$('#<%=lblNoRecords.ClientID%>').css('display','none');


$('#<%=BtnSearch.ClientID%>').click(function(e)
{
// Hide No records to display label.
$('#<%=lblNoRecords.ClientID%>').css('display','none');
//Hide all the rows.

$("#<%=GridView1Rows.ClientID%> tr:has(td)").hide();

var iCounter = 0;
//Get the search box value
var sSearchTerm = $('#<%=TxtSearch.ClientID%>').val();

//if nothing is entered then show all the rows.
if(sSearchTerm.length == 0)
{
$("#<%=GridView1Rows.ClientID%> tr:has(td)").show();
return false;
}
//Iterate through all the td.
$("#<%=GridView1Rows.ClientID%> tr:has(td)").children().each(function()
{
var cellText = $(this).text().toLowerCase();
//Check if data matches
if(cellText.indexOf(sSearchTerm.toLowerCase()) >= 0)
{
$(this).parent().show();
iCounter++;
return true;
}
});
if(iCounter == 0)
{
$('#<%=lblNoRecords.ClientID%>').css('display','');
}
e.preventDefault();
})
})
//Code Ends

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