c# - Query based on 1 or multiple fields filled in -


i'm sure super easy drawing blank. have 5 textboxes used searching. if textbox1 filled in populate gridview1, textbox2 gridview2, etc. have 4 more gridviews can populated if textbox1 or textbox2 filled populates if both filled. , gridview populate based on 1 or 3 of textboxes being filled.

is there way other switch or 500 if scenarios code populating gridview based on 1 3 search fields filled in?

in case define specific search query multiple input parameters, checks whether every parameter has value or not.

for example

-- part if use odbc connection, use sql client connection don't need declare @companyid int declare @customernumber int declare @locationid int declare @anotherfilter varchar(100)  select @companyid=?, @customernumber=?, @locationid=?, @anotherfilter=?  -- end odbc specific  select * your_table (company_id=@companyid or @companyid=0) , (customer_number=@customernumber or @customernumber=0) ,  (location_id=@locationid or @locationid=0) , (another_field=@anotherfilter or @anotherfilter='') 

you can put in sqldatasource or objectdatasource gridview(s)


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -