I have a gridview that is populated on page load. I added a search option and when user clicks button I want the matching row to be highlighted in gridview. The grid will display all the data but will only highlight the matching row. Below is my code but it doesn't highlight the matching row. Any suggestions?
Highlight search code:
Hide Copy 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, RefNo.Text.Trim(), delegate (Match match)
{
return string.Format("<span style = 'background-color:#D9EDF7'>{0}</span>", match.Value);
}, RegexOptions.IgnoreCase);
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow
{
e.Row.Cells[0].Text = Regex.Replace(e.Row.Cells[
{
return string.Format("<span style = 'background-color:#D9EDF7'
}, RegexOptions.IgnoreCase);
}
}