Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
var sSearchTerm = $('#<%=txtSearch.ClientID%>').val(); //Get the search box value
               if (sSearchTerm.length == 0) //if nothing is entered then show all the rows.
               {
                   $("#<%=dgv_AcadamicYear.ClientID%> tr:has(td)").show();
                   return false;
               }
               //Iterate through all the td.
               $("#<%=dgv_AcadamicYear.ClientID%> tr:has(td)").children().each(function () {
                   var cellText = $(this).text().toLowerCase();
                   if (cellText.indexOf(sSearchTerm.toLowerCase()) >= 0) //Check if data matches
                   {
                       $(this).parent().show();
                       iCounter++;
                       return true;
                   }
               });



Above code search value in all columns of GridView. I want to search in a single column say for example StudentID is a one column and I am searching for ID 1 in only single column
Posted
Updated 13-Sep-14 2:13am
Comments
Thanks7872 2-Sep-14 7:49am    
Its just because you are iterating through each and every td whereas you were suppose to iterate through say 3rd td(or whatever) in each row.
m-shraddha 13-Sep-14 8:13am    
what will be the 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