如何在gridview中突出显示单词

如何在gridview控件中突出显示查询文本?

如果你想做这个客户端请按照以下步骤:

添加jQuery引用到你的page.add文本输入calles txt_Search

然后使用此脚本:

  $(document).ready(function () { $('#txt_Search').keyup(function () { searchTable($(this).val()); }); function searchTable(inputVal) { var table = $('#GridView1'); table.find('tr').each(function (index, row) { var allCells = $(row).find('td'); if (allCells.length > 0) { var found = false; allCells.each( function (index, td) { var regExp = new RegExp(inputVal, 'i'); if (regExp.test($(td).text())) { found = true; return false; }}); if (found == true) $(row).show(); else $(row).hide(); } }); } }); 
 var gv = document.getElementById("#GridView1"); for (var i = 0; i < gv.all.length; i++) { var cellValue = grid.rows[i].cells[0].elements[0]; cellValuestyle.background = '#DD00DD'; } 

搜索文本,用标记打扮 ,不要忘记为标签添加高亮样式。