hi, i have a gridview search which filters the gridview, displaying the search results, however it wont highlight the results in yellow:

//Highlight relevant search results
        public string Highlight()
        {
            //Declaring a variable to hold search query
            string s = txtSearch.Text;

            if (s != null)
            {
                //string Search_Str = txtGrid.Text.ToString();  

                // Setup the regular expression    
                Regex RegExp = new Regex(s.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);

                //Highlight keywords by calling the delegate         
                //each time a keyword is found.        
                return
                   RegExp.Replace(s, new MatchEvaluator(ReplaceKeyWords));
                // Set the RegExp to null.            
                //RegExp = null;        
            }
            else
            {
                return s;
            }
        }


        // Method which helps find and highlight search results
        public string ReplaceKeyWords(Match m)
        {

            return "<span class=highlight>" + m.Value + "</span>";
        }

can any1 see a problem?
cheers

if i enter manoj sagoi than it should highlight manoj sagoi,only .currently it's highlighting all manoj inside a paragraph.

hi, i have a gridview search which filters the gridview, displaying the search results, however it wont highlight the results in yellow:

//Highlight relevant search results
        public string Highlight()
        {
            //Declaring a variable to hold search query
            string s = txtSearch.Text;

            if (s != null)
            {
                //string Search_Str = txtGrid.Text.ToString();  

                // Setup the regular expression    
                Regex RegExp = new Regex(s.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);

                //Highlight keywords by calling the delegate         
                //each time a keyword is found.        
                return
                   RegExp.Replace(s, new MatchEvaluator(ReplaceKeyWords));
                // Set the RegExp to null.            
                //RegExp = null;        
            }
            else
            {
                return s;
            }
        }


        // Method which helps find and highlight search results
        public string ReplaceKeyWords(Match m)
        {

            return "<span class=highlight>" + m.Value + "</span>";
        }

can any1 see a problem?
cheers

Welcome manoj.sagoi@gma.

If you want to ask question, start your own thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.