943,853 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 2980
  • ASP.NET RSS
Apr 21st, 2009
0

highlighting search results in a gridview problem

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

c# Syntax (Toggle Plain Text)
  1. //Highlight relevant search results
  2. public string Highlight()
  3. {
  4. //Declaring a variable to hold search query
  5. string s = txtSearch.Text;
  6.  
  7. if (s != null)
  8. {
  9. //string Search_Str = txtGrid.Text.ToString();
  10.  
  11. // Setup the regular expression
  12. Regex RegExp = new Regex(s.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);
  13.  
  14. //Highlight keywords by calling the delegate
  15. //each time a keyword is found.
  16. return
  17. RegExp.Replace(s, new MatchEvaluator(ReplaceKeyWords));
  18. // Set the RegExp to null.
  19. //RegExp = null;
  20. }
  21. else
  22. {
  23. return s;
  24. }
  25. }
  26.  
  27.  
  28. // Method which helps find and highlight search results
  29. public string ReplaceKeyWords(Match m)
  30. {
  31.  
  32. return "<span class=highlight>" + m.Value + "</span>";
  33. }

can any1 see a problem?
cheers
Reputation Points: 10
Solved Threads: 0
Light Poster
julseypart is offline Offline
42 posts
since Oct 2008
Apr 21st, 2009
0

Re: highlighting search results in a gridview problem

Reputation Points: 26
Solved Threads: 44
Posting Whiz in Training
mail2saion is offline Offline
247 posts
since Apr 2009
Feb 23rd, 2010
0

problem

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


Click to Expand / Collapse  Quote originally posted by julseypart ...
hi, i have a gridview search which filters the gridview, displaying the search results, however it wont highlight the results in yellow:

c# Syntax (Toggle Plain Text)
  1. //Highlight relevant search results
  2. public string Highlight()
  3. {
  4. //Declaring a variable to hold search query
  5. string s = txtSearch.Text;
  6.  
  7. if (s != null)
  8. {
  9. //string Search_Str = txtGrid.Text.ToString();
  10.  
  11. // Setup the regular expression
  12. Regex RegExp = new Regex(s.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);
  13.  
  14. //Highlight keywords by calling the delegate
  15. //each time a keyword is found.
  16. return
  17. RegExp.Replace(s, new MatchEvaluator(ReplaceKeyWords));
  18. // Set the RegExp to null.
  19. //RegExp = null;
  20. }
  21. else
  22. {
  23. return s;
  24. }
  25. }
  26.  
  27.  
  28. // Method which helps find and highlight search results
  29. public string ReplaceKeyWords(Match m)
  30. {
  31.  
  32. return "<span class=highlight>" + m.Value + "</span>";
  33. }

can any1 see a problem?
cheers
Reputation Points: 10
Solved Threads: 0
Newbie Poster
manoj.sagoi@gma is offline Offline
1 posts
since Feb 2010
Feb 23rd, 2010
0
Re: highlighting search results in a gridview problem
Welcome manoj.sagoi@gma.

If you want to ask question, start your own thread.
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in ASP.NET Forum Timeline: Templatefield at specific Column
Next Thread in ASP.NET Forum Timeline: Check Current date belongs to first week of current month or last week of last month





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC