Hello,
I have followed your post here:
https://www.aspsnippets.com/Articles/Search-records-in-GridView-and-highlight-results-in-ASPNet-using-C-and-VBNet.aspx
However, I want to show in the Gridview only the matched records instead of highlight them since I have so many records. Could you please help me to do this task?
Thank you very much.
Here is the code:
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = Regex.Replace(e.Row.Cells[0].Text, txtSearch.Text.Trim(), delegate (Match match)
{
return string.Format("<span style = 'background-color:#D9EDF7'>{0}</span>", match.Value);
}, RegexOptions.IgnoreCase);
}
}