Web Development



How do i select all the matching criteria in one table

By austyno23 ·
I am using on table with up to 24 fields.
I want to select from the database all user selected matching criteria from my dropdown .I am using ASP.NET and C# 3.5.If i use the and operators ,it fails and if i use the OR operators i get the wrong value from the Database.
I know that Somebody with a kind heart will help me out of this.
Please help.
This is how the Dropdown look like.
drpPrivate.ToString().Equals("Not Specified")
&& drpNational.ToString().Equals("Not Specified")
&& drpCountry.ToString().Equals("Not Specified")
&& drpFullBoard.ToString().Equals("Not Specified")
&& drpSelfCatering.ToString().Equals("Not Specified")
&& drpBudgetLevel.ToString().Equals("Not Specified")
&& drpCurrency.ToString().Equals("Not Specified")
&& drpPrimaryTourismRoute.ToString().Equals("Not Specified")
&& drpSecondaryTourismRoute.ToString().Equals("Not Specified")
&& drpBig5Safari.ToString().Equals("Not Specified")
&& drpWildernessExperience.ToString().Equals("Not Specified")
&& drpNatureExperience.ToString().Equals("Not Specified")
&& drpSpecialistSpecie.ToString().Equals("Not Specified")
&& drpAccommodationClass.ToString().Equals("Not Specified")
&& drpTravellingWithChildren.ToString().Equals("Not Specified")
&& drpAge.ToString().Equals("Not Specified")
&& drpPrimarySafariActivity.ToString().Equals("Not Specified")
&& drpMalariaRisk.ToString().Equals("Not Specified")
&& drpScheduledFlights.ToString().Equals("Not Specified")
&& drpDrive.ToString().Equals("Not Specified")
&& drpPrivateCharter.ToString().Equals("Not Specified")
&& drpBusTrain.ToString().Equals("Not Specified")
&& drpFineDining.ToString().Equals("Not Specified")
&& drpVegetarian.ToString().Equals("Not Specified")
&& drpKosher.ToString().Equals("Not Specified")
&& drpHalal.ToString().Equals("Not Specified")
&& drpWedding.ToString().Equals("Not Specified")
&& drpHoneyMoon.ToString().Equals("Not Specified")
&& drpExclusiveUse.ToString().Equals("Not Specified")
&& drpSpa.ToString().Equals("Not Specified")
&& drpDisabledFacilities.ToString().Equals("Not Specified")
&& drpConference.ToString().Equals("Not Specified")
&& drpGreen.ToString().Equals("Not Specified")
&& drpConferenceDelegates.ToString().Equals("Not Specified")
&& drpCampSize.ToString().Equals("Not Specified")
&& drpGroupSize.ToString().Equals("Not Specified")
&& drpSunRating.ToString().Equals("Not Specified")
&& drpStarGrading.ToString().Equals("Not Specified")
&& drpGym.ToString().Equals("Not Specified")
&& drpBusinessCentre.ToString().Equals("Not Specified")
&& drpBoma.ToString().Equals("Not Specified")
&& drpSwimmingPool.ToString().Equals("Not Specified")
&& drpWiFiInternet.ToString().Equals("Not Specified")
&& drpPrivatePlungePool.ToString().Equals("Not Specified")

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -

Hard to code and hard to use that

by Tony Hopkinson In reply to How do i select all the m ...

I'd have two list boxes, one with possible selections and one with selections made.
A couple of buttons to add and remove to selected

That will cut out all the not specified fellows, and it's just a question of building a query string from what in selected.

I'sd be using a simple struct to hold selection as
well Displayname, fieldname, may be a value (can't tell if all these are booleans)
and an enum for operator (and or perhaps even not)

Then you just need a method that will take list of selections and build a query string from FieldName, value ? and operator.

If they are all booleans and you only want to with any of these or all of these.

One listbox with multiselect and range select on, and then a bit of code to iterate through selecteditems and build the query would do the job as well.

Personally I find that sort of UI a bit fiddly though.

Related Discussions

Related Forums