Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET VB.NET
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 29-Jan-13 4:22am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Based on what you have shared, one of the ways to handle string values is to use LIKE keyword along with wild card character %.
 
SELECT 
 *
FROM
  myTable
WHERE
  colName LIKE '%somevalue%'
Like this, even if there is no value, everything will be selected.
  Permalink  
Comments
Member 9207317 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,455
1 OriginalGriff 8,295
2 Peter Leow 4,839
3 Kornfeld Eliyahu Peter 3,210
4 Maciej Los 2,301


Advertise | Privacy | Mobile
Web03 | 2.8.150327.1 | Last Updated 29 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100