Filter ASP.Net GridView based on multiple DropDownList selection using C# and VB.Net

Last Reply 7 months ago By dharmendr

Posted 7 months ago

Hello everyone

I have designed a webform with 6 dropdownlist controls and a gridview control. The gridview get filled with data based on any dropdownlist selection. Each dropdownlist consist of an option "ALL" holding value 0. To get data from database I am checking the value of every dropdownlist with multiple possibilities using if elseif statements. If user selects "ALL" I am, excluding that parameter from WHERE clause and passing those parameter value which is !="ALL". My code is working fine but I am trying to reduce my code. I have tried a lot to generate where clause dynamically but I am not getting how to exclude the parameter whose selected value = "ALL" or 0. Kindly help me out in acheiving this, any suggestions will be appreciated.