Using Drop Down List with Gridview Query

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?
 
D

David Wier

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)
 
B

Bishop

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?
 
D

David Wier

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top