473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Drop Down List with Gridview Query

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
4 6642
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Phil Longworth | last post by:
Im very new to Access 97 and Im sure I should be able to do this but cant work out how. Im bulding a database for my stamp collection. I have two tables; one with details of all the individual...
2
by: kmnotes04 | last post by:
Is it possible to link one drop-down box to another? For example, if a name is chosen from a drop-down list, can another drop-down list then automatically display the person's office as a result of...
1
by: mimo | last post by:
Hi, I'm trying to use Stored Procedures with a Grid View and everytime I try the update and the delete stored procedures fail. By the way I am doing this through the wizard. Is there a...
1
by: CSharpguy | last post by:
Let me explain, I have 2 drop downs on my web form and they populate my gridview via a button and a stored procedure. I have 2 links in my GridView, I need to pass the value of one of the drop...
0
by: ayneekeaw | last post by:
When I click the update button/link at the Gridview to update the data from drop down list into the SQL. The selected value of drop down list change to default value. How can I fix this problem
0
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in...
3
by: SQLjunky | last post by:
Hello, Contrary to what my screen name indicates, i'm actually quite new to SQL. Having said that, I'll get right into my problem. I'm trying to query an mssql database to return to the value...
2
by: McGeeky | last post by:
Hi. I have a read only GridView. For each row I want to display a drop down list which contains a list of actions the user can select from for that particular row. E.g. "view details". When they...
7
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
Is there a way to use a gridview in a timecard application, and if so, how? I was looking at using a gridview to display a person's hours worked in a week. To do this, many different data records...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.