Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
TextBox t = (TextBox)sender;
      var sbFilter = new System.Text.StringBuilder(200);

      //marto gridvie1 sexedavs
      if (t.Text.Length > 0) {
          sbFilter.Append(t.ID + "Like %'").Append(t.Text).Append("'%");

      ObjectDataSource1.FilterExpression = sbFilter.ToString();
      }
      else{
          ObjectDataSource1.FilterExpression = string.Empty;
          ObjectDataSource1.FilterParameters.Clear();

      }

i have this code for Search In GridView in Row but when i use instead of Like "=" it is working perfectly but i have to Search Whole Word i want to Use Like but when i am doing like this It is Erroring mee i tried lots of Combination '% << this one but didn't helped Can anyone Help me?
Posted

1 solution

Nothing looks wrong to me.
Only concern are-
1. Make sure that you text doesn't exceed 200 characters.
2. Instead you can initialize a StringBuilder object without specifying a limit (if it is not the need of your program)
3. Make sure that your input text doesn't contains special characters like '(single quote)

Hope, these would help resolving your issue.

Else, please share details of the error you are getting so that we can identify the actual issue and will be able to suggest more clear solution.

Thanks.
 
Share this answer
 
Comments
GTR0123 14-Dec-15 1:09am    
i make my StringBuilder without specification here is some errors what i get i am trying some combination of % << '' << this
Syntax error: Missing operand after 'Mod' operator.
Cannot find column [IDLike].
Syntax error: Missing operand after ''%'' operator.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900