| |

VerySource

 Forgot password?
 Register
Search
View: 1405|Reply: 12

Multi-criteria search questions !!!

[Copy link]

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-1-29 20:40:01
| Show all posts |Read mode
There are multiple dropdownlists on the page, the contents of which are linked menus of regions, provinces, and cities, and a textbox for entering keywords. A search button ...

Each dropdownlist has all of this option.The purpose I want to achieve is to display the corresponding items from the database based on so many conditions + keywords. Of course, if not selected in the dropdownlist, it is equivalent to selecting all

How to write a statement in such a search situation ???

Help me !!!
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-3-3 23:45:01
| Show all posts
string strSQL = "Select * from table where 1 = 1";

if (dropdownlist1.SelectedValue.Trim ()! = "")
{
   strSQL + = "and field 1 = '" + dropdownlist1.SelectedValue + "'";
}

if (dropdownlist2.SelectedValue.Trim ()! = "")
{
   strSQL + = "and field 2 = '" + dropdownlist2.SelectedValue + "'";
}
Reply

Use magic Report

0

Threads

23

Posts

21.00

Credits

Newbie

Rank: 1

Credits
21.00

 China

Post time: 2020-3-4 13:45:01
| Show all posts
string temp = "";
if (dropdownlist1.selectedvalue.tostring (). Equals ("all"))
temp = "1 = 1 and";
else
temp = "field name = '" + dropdownlist1.selectedvalue + "' and";
if (dropdownlist2.selectedvalue.tostring (). Equals ("all"))
temp = temp + "1 = 1 and";
else
temp = "field name = '" + dropdownlist2.selectedvalue + "' and";
...............
The last one removes and
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-3-7 15:30:02
| Show all posts
I searched on the homepage, and then displayed it on other pages. It was displayed using a repeater. I have to pass the value.
Reply

Use magic Report

0

Threads

7

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-8 01:00:01
| Show all posts
Set the value of DropDownList as a keyword

Then concatenate the strings
Reply

Use magic Report

1

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-3-22 14:30:01
| Show all posts
Address bar or session by value

It's better to use the address bar, and it's better to encrypt
Reply

Use magic Report

1

Threads

12

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-3-22 15:00:02
| Show all posts
Pass the conditions, and then read the data on the page you need to display
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-23 01:15:01
| Show all posts
If the provinces, cities and counties are linked, only one parameter should be sufficient, because if it is Changsha, it must be Hunan Province.

Pass this parameter and query keywords directly in the form of QueryString and it will be OK
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-3-23 14:00:01
| Show all posts
Then if one of the pass values ​​is not selected, it will be wrong ...
Reply

Use magic Report

1

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

 Author| Post time: 2020-5-4 20:00:01
| Show all posts
It seems wrong
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list