Click here to Skip to main content
15,883,975 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am applying filtering in DevExpress AspxGridView.
For filtering I'm sending the values for filtering from code side and filtering the records in sql server 2005 by these values.

Now my requirement is that the user can select any values for filtering means suppose I have 7 controls for giving option to user to filter then user is free to select any of controls to filter database according to selected values.

Now the problem is occurring when I use And statement in my where clause in stored procedure, it's not displaying any field because it filtered if all number of parameter values are sent.
And if I use Or in Where clause then it's displayed all values and not filtered according to selected values.

Can anyone suggest me how can I solve this issue.

Thanks in Advance.

Regards,
Posted

1 solution

Based on what you have shared, one of the ways to handle string values is to use LIKE keyword along with wild card character %.

SQL
SELECT 
 *
FROM
  myTable
WHERE
  colName LIKE '%somevalue%'

Like this, even if there is no value, everything will be selected.
 
Share this answer
 
Comments
Member 9207317 31-Jan-13 3:37am    
Hello Sandeep

Thanks for your great help..

Yes, the Like clause solved the issue, but I am sending multiple id's in the paramter, So it's not worked correctly with Like clause.

Also I'm using a function which split the values:

Suppose In parameter @p I have '1,2,3' Id's then my function is spliting these id's by
@Split(@p,',') and worked well when I am applying this with "In ( Select * from split(@p,',')).

Please let me know how can use the Like clause also by using this function.

Thanks in Advance.

Regards,

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