473,395 Members | 1,497 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,395 software developers and data experts.

Dynamic asp:DrownDownList control

Bob
I have a static AutoPostBack asp:DrownDownList and depending on the selected
content of this list, I want to either 1) not do anything or 2) generate and
populate a new asp:DrownDownList below it. How do I do this on the server
side? I am trying to do this with minimal client-side JavaScript being
generated.

Thanks
Dec 6 '07 #1
3 1011
If I'm understanding you correctly, we're talking about the following
hypothetical scenario: You have a country list and when the user makes a
selection you either do nothing or you load a list of States/Regions
depending on the selection made?

If that scenario is near enough, you could consider the following approach:
At design time, create the second dropdownlist where ever it should be and
set it's visibility to false, or if you don't mind the user seeing it, set
it's enabled property to false.

Capture the Country list's SelectedIndexChanged event and based on your
conditions either load the second list or do nothing.

eg.
protected void Countries_SelectedIndexChanged(....,....)
{
if (Countries.SelectedIndex 0)
{
Regions.DataSource =
BizLayer.GetRegions(Convert.ToInt16(Countires.Sele ctedValue));
Regions.DataTextField = "textField";
Regions.DataValueField = "valueField";
Regions.DataBind();
}
}

Make sure your viewstate is enabled for these lists else you may not get the
expected result.

Hope this helped.
Cheers
Jacques

"Bob" wrote:
I have a static AutoPostBack asp:DrownDownList and depending on the selected
content of this list, I want to either 1) not do anything or 2) generate and
populate a new asp:DrownDownList below it. How do I do this on the server
side? I am trying to do this with minimal client-side JavaScript being
generated.

Thanks
Dec 7 '07 #2
Bob
Thanks for your response. However on the internet I found exactly what I
was looking for in the following article:

http://aspnet.4guysfromrolla.com/articles/081402-1.aspx

Thanks again.
Dec 7 '07 #3
Have you looked at ASP.Net AJAX? There is a control already built that does
this.

David
"Bob" <no****@nowhere.comwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
Thanks for your response. However on the internet I found exactly what I
was looking for in the following article:

http://aspnet.4guysfromrolla.com/articles/081402-1.aspx

Thanks again.

Dec 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: charliewest | last post by:
I need to create textboxes in real-time, the actual number of which is determine by a result from a database query. I have been able to create the controls, and then add them to the ASPX page....
3
by: Assaf | last post by:
Hi all. In response to user selections, our app adds controls (buttons, image buttons) dynamically to a page with Controls.Add(myNewButtonControl). Now that we gotten on the page we want to...
5
by: RA | last post by:
I have created a button dynamically; which has been added to a TableCell of a TableRow of a Table control. Is there a way to add onclick event which calls a procedure on the Server-side itself....
2
by: Matt | last post by:
Hi, Can someone provide some information on how to create a control dynamically based on the contents of another dynamic control. In my experience, all dynamic controls must be created in the...
1
by: amirmira | last post by:
I have a multithreaded application is ASP.NET that checks the status of a process every 2 seconds. After the thread has completed, the values of dynamically added controls need to be changed...
2
by: dawg1998 | last post by:
I have a page that creates dynamic textboxes based on the number of fields a user chooses to fill out. This process worked great when the page was standalone. However, when I move to a...
1
by: Larry Bud | last post by:
A dynamic control (A dropdown) is created in PageLoad, but the value of the dynamic control dictates where it's added (such as which cell in a table) on a postback. Seems like a catch-22. I...
1
by: Manoj Mittal | last post by:
I have created the Dynamic control in asp.net c# like for (int i = 1; i <= 5; i++) { Label label = new Label(); label.ID = "Label" + i; label.Text = "Label"+i; form1.Controls.Add(label); }
0
by: imranabdulaziz | last post by:
hi all , i am mess with the one situation. i am using asp.net2.0 ,C# and sql server 2005. I have checkboxlist and based on user selection i creates dynamic controls(which code is in...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.