change specific words color in gridview
hi friends this is kavita
can any body tell me how to change specific string color at runtime i.e. I have a field in database "detail" and I m showing it into gridview by using in a table like this:
.........
<%#Container.DataItem("detail")%>
and I want some special word which is enter by user are display in blue color.
like if user enter"computer" and "detail"(it is a database field) contain "computer is a good" then in gridview the word"computer" display in blue color.
please give me answer?
can any body help me?
kavitaPosted Jul 11, 2007, 2:31 AM
Public
Function Highlight(ByVal InputTxt As String) As String Dim i As Integer Dim Search_Str As String = key Dim arr_color As String() Dim highlight_str As String = ""highlight_str = InputTxt
arr_color = Search_Str.Split(
" ") For i = 0 To UBound(arr_color) ' Setup the regular expression and add the Or operator. Dim RegExp As Regex = New Regex((arr_color(i).Trim()).Replace(" ", "").Trim(), RegexOptions.IgnoreCase) ' Highlight keywords by calling the MatchEvaluator delegate each time a keyword is found.highlight_str = RegExp.Replace(highlight_str,
New MatchEvaluator(AddressOf ReplaceKeyWords)) ' Set the Regex to nothing.RegExp =
Nothing NextHighlight = highlight_str
End Function Public Function ReplaceKeyWords(ByVal m As Match) As String Return "" & m.Value & "" End Functionand it's working
luo skyweiPosted Jul 10, 2007, 12:45 PM
2.You Add this component to gridview's DataGridTableStyle To display it