473,800 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using Drop Down List with Gridview Query

I have a query similar to this: "Select ProductID, ProductName,
ProductDescript ion 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 6659
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******** *****@TK2MSFTNG P06.phx.gbl...
I have a query similar to this: "Select ProductID, ProductName,
ProductDescript ion 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********@noS pamhotmail.comw rote in message
news:%2******** ********@TK2MSF TNGP02.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******** *****@TK2MSFTNG P06.phx.gbl...
>I have a query similar to this: "Select ProductID, ProductName,
ProductDescrip tion 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="Sele ct.....
else
mySQLTExt="Sele ct...something else"
end if

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam. comwrote in message
news:u6******** ******@TK2MSFTN GP02.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********@noS pamhotmail.comw rote in message
news:%2******** ********@TK2MSF TNGP02.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******** *****@TK2MSFTNG P06.phx.gbl...
I have a query similar to this: "Select ProductID, ProductName,
ProductDescript ion 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********@noS pamhotmail.comw rote in message
news:us******** ******@TK2MSFTN GP04.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="Sele ct.....
else
mySQLTExt="Sele ct...something else"
end if

--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
"Bishop" <no****@nospam. comwrote in message
news:u6******** ******@TK2MSFTN GP02.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********@noS pamhotmail.comw rote in message
news:%2******* *********@TK2MS FTNGP02.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******** *****@TK2MSFTNG P06.phx.gbl...
I have a query similar to this: "Select ProductID, ProductName,
ProductDescrip tion 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
2660
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 stamps, and one with details of covers/envelopes the stamps are fixed to. Each indivdual stamp has a specific reference number (not an auto-number). Rather than manually enter the reference number into my 'covers/envelopes' table I want Access to...
2
9477
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 the choice made in the first drop-down list? If so, how can that be done? I am working with 'Teach Yourself Microsoft Access' and I didn't see it discussed in that book (if it's even possible to do). Or would I just have to create linked tables...
1
2164
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 sample somewhere on how to do this? When I type in the statements directly it works, but I really need to be able to call stored procedures. And the stored procedures work fine in query analyzer.
1
1256
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 downs in my URL via the query string and that value is not returned in the stored procedure that is loading the grid. So how can I get the selectedItem.value from the drop down and pass it in the querystring in my gridview link?
0
2648
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
2168
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 edititemtemplate with preselected value from the previous drop down list, so far I can only achieved with the regular drop down list in edititemtemplate with no preselected value from previous one. anyone can help me. thanks in advance. below is my current...
3
2169
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 that the user inputs through a drop-down menu in the databases GUI front-end (bugzilla actually). For example, a product is selected in a drop-down menu, and, depending on the product chosen, a second drop-down menu becomes active, containing a list...
2
14394
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 select an action in the drop down list I want to do a post back. How will I know which row they made the selection in? Is there a way to embed the row Id in the drop down list so it gets sent back to the server? Thanks
7
3340
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 would have to display on the same row to make up a week (the database has a new row for each day entered). But, from what I can tell, this keeps you from being able to use a gridview, because the gridview relies on one datakey per row (and there...
0
10514
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10287
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10042
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7588
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6826
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5479
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5616
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3770
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2956
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.