Using Drop Down List with Gridview Query

  • Thread starter Thread starter Bishop
  • Start date Start date
B

Bishop

I have a query similar to this: "Select ProductID, ProductName,
ProductDescription where MFGID = @MFGID". I use a Drop Down List populated
with the MFGID's to populate the @MFGID variable. My question is, using
this technique, is there a way to say "Return all Manufactures"? If not,
any suggestions on a good technique for this?
 
You might add a 'Select All' item to the top of the dropdownlist (item 0) -
give it a value of -1
Then, make your stored procedure have an if/then, so that if @MFGID is -1,
return all, if not, use your other sql statement

You can do this in code, also, if you're not using Stored Procedures
(however, doing so would probably be a good idea)
 
The query is bound to the gridview and I'm trying to avoid changing it with
my VB Code. Can I use If/Then in my SQL query without it being a stored
procedure?
 
You'd just need to add an if/then in your code, where you are implementing
your Select statement:
if (whatever) then
mySQLTExt="Select.....
else
mySQLTExt="Select...something else"
end if
 
Back
Top