473,396 Members | 1,995 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.

How to add items in DropDownListbox if I select another DropDownListbox

Dear Friends

This is Jeyapriya. Right now I am working in the ASP.NET with VB coding & the back end is SQL SERVER 2000.

My dilemma is

I have to design a form with 2 DropDownListboxes. I have to load the ‘names of the theater’ on the 1st DropDownListbox & the names of the movie on the second DropDownListbox. That’s why I have created 2 tables named ‘theater’ and ‘movie’ on sql server 2000. The ‘theater’ table consists of 2 fields
1) tid
2) tname

The movie table has 2 fields

1) mid
2) mname

If I select a item in theater DropDownListbox, then the corresponding movies should be filled on the movie DropDownListbox. And by default, both the DropDownListboxes should show ‘CHOOSE’(‘Choose Theater’ in Theater-DropDownListbox and ‘Choose Movie’ in Movie DropDownListbox)

Now the problem is, I don’t know what is the next step to do.
Mar 19 '08 #1
1 1685
balabaster
797 Expert 512MB
Dear Friends

This is Jeyapriya. Right now I am working in the ASP.NET with VB coding & the back end is SQL SERVER 2000.

My dilemma is

I have to design a form with 2 DropDownListboxes. I have to load the ‘names of the theater’ on the 1st DropDownListbox & the names of the movie on the second DropDownListbox. That’s why I have created 2 tables named ‘theater’ and ‘movie’ on sql server 2000. The ‘theater’ table consists of 2 fields
1) tid
2) tname

The movie table has 2 fields

1) mid
2) mname

If I select a item in theater DropDownListbox, then the corresponding movies should be filled on the movie DropDownListbox. And by default, both the DropDownListboxes should show ‘CHOOSE’(‘Choose Theater’ in Theater-DropDownListbox and ‘Choose Movie’ in Movie DropDownListbox)

Now the problem is, I don’t know what is the next step to do.
Firstly run a query to pull a list of your theatres using an SqlCommand and an SqlDataReader. Bind the query results to the first dropdownlist using DropDownList1.DataSource = MyDataReader1

In the SelectedIndexChanged event of the first dropdownlist, trigger a database query to select the movies at that theatre. Use the same method to bind the query results to the second dropdownlist.

In the DataBound event of each of the dropdownlists, insert the "Select..." entry at the beginning of the dropdownlist using DropDownList.Insert(0, "Select..."). You can comma separate the Handles clause to use the same code, but you'll have to CType the sender to DropDownList: CType(Sender, DropDownList).Insert(0, "Select...").

It's a relatively straightforward process...you should be able to find the relevant information easily by picking keywords out of what I've written.

Lastly, I would use an AJAX extender to run the second query - this way you don't have to reload the whole page after the user selects the theatre - the second dropdown will be populated in the background.
Mar 19 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Max | last post by:
Have a DropDownListBox where I want to give users the option to select one of the values, but allow them to enter a freeform text value if they choose to do so in lieu of the proffered values. Kind...
7
by: Eduardo M?ndez | last post by:
Hello: I have an aspx page with a TextBox and a DropDownListBox both have Autopostback property set to true and some code in the TextChanged and SelectedIndexChanged events. When text in...
3
by: Do | last post by:
Hi, How do I read through the items that are statically set in a dropdownlistbox? Usually, I have my items in a dataset before I bind to a control, so I can read the data. But if they're set...
4
by: | last post by:
I think we have some bug in dropdownlistbox server control. Following are the values. <asp:DropDownList id="DropDownList1" runat="server"> <asp:ListItem value="46">INR</asp:ListItem>...
1
by: pari kanaga | last post by:
I have server control dropdownlistbox populated with data from table. I don't know how to make this dropdownlistbox searchable. ( for example if i click the dropdownlistbox and type the name it...
1
by: raj | last post by:
hello i want to set the tooltip of data displaying in dropdownlistbox , i have bound the dropdownlistbox with datasource and i want that tooltip shld be display at every item of dropdownlistbox...
1
by: Ted | last post by:
Here is a stored procedure I created in MySQL: CREATE PROCEDURE `sp_find_food`( IN search_string varchar(255) ) BEGIN DECLARE ss VARCHAR(257); SET ss = CONCAT('%',search_string,'%'); SELECT...
3
by: BenCoo | last post by:
Hi, I have a gridview control that displays data from 2 tabels in a sqlserver 2005 database. The table "Temperatures" has a field "LocationID" I populate the gridview with a ObjectDataSource...
2
by: Kenichi666 | last post by:
I am new to ASP.NET and C#. I have populate a dropdownlistbox from a sqltable. I would like to set the selected value in the dropdownlistbox to an sql UPDATE command. like fx. "UPDATE name =...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...

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.