vendredi 18 août 2017

Filtering a GridView programatically with Checkboxes

I'm creating a project tracker ASP.net wbsite with C# for my codebehind. My default view has a GridView that queries a SQL Server DB, and one of the columns is Project Status (ProjStatus), which can have 5 different options (In Progress, Pending, Complete, Postponed, Cancelled).

Now, I need to create an incremental filter using a checkbox list. For example, if I select the checkbox for "In Progress" I would only want to see "In Progress" projects, but if I also check the "Pending" checkbox then I would want to see both and so forth.

I previously only had 3 status (In Progress, Pending and Complete) and I had solved this problem by hard coding each checkbox combination using if statements, but since there's 5 now there's too many possible combinations and it would take me too long to do that. Any suggestions to do this programatically in my codebehind?

Thank you!




Aucun commentaire:

Enregistrer un commentaire