I have a resultgridview from a search query.
In this gridview I have a text e.g. “This is a nice Car for you”
If the user search for the word “Car” I like to show the word “Car” in the string in the gridview in red and bold.
How to do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You should define a css-class f.e.:
… and in GridView.RowDataBound you could split the name into the parts that match and the parts that do not match. In the TemplateField of the Gridview-Column with the name you could f.e. add a Div(runat=”server”). In RowDataBound you can find it with its id, its from Type HtmlGenericControl. Then you can use the InnerHtml property to assign the match part’s span its searchmatch-css-class.
UPDATE: I think this could be helpful in GridView too: Highlighting Search Keywords in a DataGrid Web Control