Tinsae Teku

Tinsae Teku

  • 2.1k
  • 6
  • 419

How can I search only checked items from database [ASP.NET]

Jan 19 2022 1:35 PM

Let me explain my issue using a simple example: I have a table with attributes 'id' , 'age', 'sex' and 'grade'. Then I have many student's data list. I have already managed to insert specific data (For example: '0001', '12', 'male' and 'B+') into the checkbox. Now if '12' and 'male' are checked, I want my gridview to display only students whose sex are male and age is 12. If I checked three attributes, I want data with three of the attributes, not just one or two of them. To do that I have to use if...else and I am expected to do something like if(age && sex) or if(age && sex && grade) or if(grade) ... But the issue is I got so many columns (attributes). In order to address all combinations of 8 columns, I need to have 8! (8*7*6*5*4*3*2*1) i.e. 40,000+ if-else scenarios. That is like impossible. So is there any solution I can deal with this? I have already built a beautiful system and left with this issue only. Your help means a lot!

What I have tried:

I have already tried to use checkbox list. But that is only for list items of one column. But I need to take the items from different columns (4 in my previous example).


Answers (1)