Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
potn1
Starting Member
33 Posts |
Posted - 2011-04-01 : 11:04:30
|
| Hi I have a list of records that are displayed in a table. One of the columns in this table is a Job_Types. This table is originally generated and sorted in a dropdown based on name for example. All of these are done through a pretty basic SQL statement.There are roughly 150 different Jop_Types that are possible. Within this table I then want to be able to display only specific Job_Types if wanted. So essentially I may want another dropdown where a user could select for example only ‘Landscaping’ Job_Types and then only these would be displayed on a table. But then I got to thinking how would I or would I even want to display 150 different items in a dropdown on a page? Would I possibly want to pass Job_Types as a paremeter in my WHERE clause of my SQL?Any help is appreciated.Thanks! |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-01 : 15:48:15
|
| You can certainly pass in Job_Types as a parameter, either a single job type, or with a little bit more work, a sub-set of the Job_Types as parameters. That, of course, assumes that you have a job_type column in your table against which to apply a where condition.If you can post the query that you are currently using along with the DDL for the tables, some of the people on this forum may be able to offer advice/suggestions. |
 |
|
|
potn1
Starting Member
33 Posts |
Posted - 2011-04-01 : 16:05:31
|
| It now comes down to me having 2 fields displayed in a table (Job_Type, Jobs). For each ‘Job_Type’ there can be 1 to many ‘Jobs’. I essentially am looking to have 2 dropdown lists. What you select in ‘Job_Type’ will affect what is displayed in the ‘Jobs’1. Can I populate the query results from a column in a table to display in a drop down list? So say I have 50 ‘Job_Type’ is there a quick way to get my results to be options in a drop down list?2. Once a ‘Job_Type’ is selected the next drop down list (Jobs) will need to filter to only display ‘Jobs’ based on that specific ‘Job_Type’. I have been doing some research on this and is this basically using CascadingDropDown?Thanks! |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-01 : 16:16:10
|
| Depending on what tools you are using for your presentation layer and the volume of data it may be easier to do it in the presentation layer. In C#/.Net, you can use complex data binding to populate and keep parent and child controls in sync. You would get all the data for Job Types and Jobs and relate them and bind to two controls.Alternatively, you could manage it yourself by querying the database each time the user changes the selection in Job Types. But that would require a lot of round-trips to the database (Imagine if the user is holding down the down arrow with the Job Types drop down selected). |
 |
|
|
potn1
Starting Member
33 Posts |
Posted - 2011-04-01 : 16:22:49
|
| What would be the best way to populate a column from a query into a dropdown list?This is being done in vb.net and my current query is in the data access layer. The population/build of the actual report is done in the ascx.vb file. |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-01 : 16:31:04
|
| This link has an example from MSDN which shows you how to get data from a database and bind to a control in ASP.net. http://support.microsoft.com/kb/307860There are tons of tutorials and examples on doing this very thing; search for them on vb.net sites or forums. If you are using Winforms, there are similar examples available. |
 |
|
|
|
|
|