Hi everyone,I have asked similiar question before where I have two control on the page header says "username" and "gender". User can select both the control or either one and the page will execute searching based on the criteria supplied. So if username suppliedSELECT * FROM [this_table] WHERE username = @username and if gender suppliedSELECT * FROM [this_table] WHERE gender = @gender and if both supplied SELECT * FROM [this_table] WHERE username = @username AND gender = @genderI know this sounds not very complicated but in my case, I am having like more than 10 controls up there. It is something like username, gender, age, date of brith, title, father name, frst name, last name, blur blur blur and it's a lot then I started to lost. if i were to use if else caluse on code-behind and produce query, it would end up writing a lot of if-else and if i use stored procedure (with if-else) then my stored procedure would contains a lot of if-else statement. I am fairly new to this concept and if I'm on the wrong track, please correct me. Is there any better way to save my hair without actually going through each if-else statement to build the query ? Thanks all.p.s. I'm using GridView and SqlDataSource command to display the result back on .aspx page.
View Complete Post