Last post Apr 22, 2015 09:26 AM by claudio7810
Apr 21, 2015 11:40 AM|Claudio7810|LINK
I have a question about how to efficiently filtering the data fetched from MSSQL server in a way like many websites are currently doing. As for example, let's suppose I have a gridview/listview which is populated with some fruits name like apple, strawberry,
watermelon, by Name, etc etc.
The structure of the DB would be:
Fruit ID, Fruit Name, Fruite Color, Fuit Country of Origin, etc.
Then, once I retrieve the data in my gridview/listview with a simple sql select statement, I would like to add a filtering section using some checkboxes to filter by:
Fuit Country of Origin, etc.
How would you suggest to accomplish this filtering capabilities in an efficient way?
Apr 21, 2015 01:31 PM|Rajat|LINK
As I understand you require filtered data but based on checkbox
So use a stored procedure with optional parameters and call it from your DAL
Create Procedure proc_FilterFruit
@fruitId INT = -1,
@FruitName VARCHAR(100) = NULL,
@Fruitcolor VARCHAR(100) = NULL,
@Country VARCHAR(100)= NULL
SELECT Fruit ID, Fruit Name, Fruite Color, Fuit Country of Origin
WHERE (@FruitId IS NULL OR (FruitId = @FruitId))
AND @fruitName IS NULL OR (FruitName = @FruitName)
I hope the above trick will help you.
Apr 22, 2015 06:32 AM|Claudio7810|LINK
Thank you for your feedback.
Probably my question was not really well formulated but I am seeking a direction/method rather than in which way should I need to retrieve data.
In websites such as Booking.com or Expedia.com (as for example), when you are the city page you can see on the left a menu where users can select one or all options available and their results get filtered according to the selection of one or more checkboxes.
When a checkbox is unchecked, the results get filtered again removing the filter associated to that checkbox.
How can I produce such filtering capabilities considering the following points:
Thank you so much and looking forward to receiving your feedbacks
Apr 22, 2015 09:26 AM|Claudio7810|LINK
I got the answers I needed in