By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,515 Members | 1,339 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,515 IT Pros & Developers. It's quick & easy.

Using Drop Down List with Gridview Query

P: n/a
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?
Dec 18 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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)

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam.comwrote in message
news:ei*************@TK2MSFTNGP06.phx.gbl...
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?


Dec 18 '06 #2

P: n/a
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?

"David Wier" <da********@noSpamhotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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)

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam.comwrote in message
news:ei*************@TK2MSFTNGP06.phx.gbl...
>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?



Dec 18 '06 #3

P: n/a
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

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam.comwrote in message
news:u6**************@TK2MSFTNGP02.phx.gbl...
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?

"David Wier" <da********@noSpamhotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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)

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam.comwrote in message
news:ei*************@TK2MSFTNGP06.phx.gbl...
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?



Dec 18 '06 #4

P: n/a
OK, Thanks for the info!

"David Wier" <da********@noSpamhotmail.comwrote in message
news:us**************@TK2MSFTNGP04.phx.gbl...
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

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam.comwrote in message
news:u6**************@TK2MSFTNGP02.phx.gbl...
>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?

"David Wier" <da********@noSpamhotmail.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
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)

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam.comwrote in message
news:ei*************@TK2MSFTNGP06.phx.gbl...
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?




Dec 18 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.