<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Hosting Open Forum</title><link>http://forums.asp.net/158.aspx</link><description>General discussions concerning ASP.NET in a Windows Hosting environment</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: create dropdownlist in runtime with event to create another dropdown.</title><link>http://forums.asp.net/thread/689709.aspx</link><pubDate>Sat, 11 Sep 2004 19:39:09 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:689709</guid><dc:creator>llangleyben</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/689709.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=689709</wfw:commentRss><description>Read &lt;a target="_new" href="http://www.codeproject.com/aspnet/dynamiccontrols.asp"&gt;this article&lt;/a&gt;.</description></item><item><title>Re: create dropdownlist in runtime with event to create another dropdown.</title><link>http://forums.asp.net/thread/689448.aspx</link><pubDate>Sat, 11 Sep 2004 06:49:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:689448</guid><dc:creator>joteke</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/689448.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=689448</wfw:commentRss><description>I have written small example which you need to modify to suit your needs but it demonstrates one way to deal with dynamical controls on Page.
&lt;br /&gt;

&lt;br /&gt;
&lt;pre&gt;
&lt;br /&gt;
private void Page_Load(object sender, System.EventArgs e)
&lt;br /&gt;
		{
&lt;br /&gt;
			if(ShouldCreateUsaDDL)
&lt;br /&gt;
			{
&lt;br /&gt;
				CreateUSA();
&lt;br /&gt;
			}
&lt;br /&gt;

&lt;br /&gt;
			if(ShouldCreateBrazilDDL)
&lt;br /&gt;
			{
&lt;br /&gt;
				CreateBrazil();
&lt;br /&gt;
			}
&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;
		
&lt;br /&gt;
		//Button click handler to indicate we want to create a DDL for USA
&lt;br /&gt;
		private void Button1_Click(object sender, System.EventArgs e)
&lt;br /&gt;
		{
&lt;br /&gt;
			if(!ShouldCreateUsaDDL)
&lt;br /&gt;
			{
&lt;br /&gt;
				CreateUSA();
&lt;br /&gt;
				ShouldCreateUsaDDL=true;
&lt;br /&gt;
				ShouldCreateBrazilDDL = false;
&lt;br /&gt;
			}
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;
		public bool ShouldCreateUsaDDL
&lt;br /&gt;
		{
&lt;br /&gt;
			get
&lt;br /&gt;
			{
&lt;br /&gt;
				object obj=ViewState[&amp;quot;ShouldCreateUsaDDL&amp;quot;];
&lt;br /&gt;
				return (obj==null)? false : (bool)obj;
&lt;br /&gt;
			}
&lt;br /&gt;
			set
&lt;br /&gt;
			{
&lt;br /&gt;
				ViewState[&amp;quot;ShouldCreateUsaDDL&amp;quot;]=value;
&lt;br /&gt;
			}
&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
		public bool ShouldCreateBrazilDDL
&lt;br /&gt;
		{
&lt;br /&gt;
			get
&lt;br /&gt;
			{
&lt;br /&gt;
				object obj=ViewState[&amp;quot;ShouldCreateBrazilDDL&amp;quot;];
&lt;br /&gt;
				return (obj==null)? false : (bool)obj;
&lt;br /&gt;
			}
&lt;br /&gt;
			set
&lt;br /&gt;
			{
&lt;br /&gt;
				ViewState[&amp;quot;ShouldCreateBrazilDDL&amp;quot;]=value;
&lt;br /&gt;
			}
&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;
		private void CreateUSA()
&lt;br /&gt;
		{
&lt;br /&gt;
			DropDownList list=new DropDownList();
&lt;br /&gt;
			list.ID=&amp;quot;USA&amp;quot;;
&lt;br /&gt;
			list.Items.Add(&amp;quot;Tallahassee&amp;quot;);
&lt;br /&gt;
			list.Items.Add(&amp;quot;Tennessee&amp;quot;);
&lt;br /&gt;
			list.Items.Add(&amp;quot;Washington&amp;quot;);
&lt;br /&gt;
			PlaceHolder1.Controls.Clear();  
&lt;br /&gt;
			PlaceHolder1.Controls.Add(list);
&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;
		private void CreateBrazil()
&lt;br /&gt;
		{
&lt;br /&gt;
			DropDownList list=new DropDownList();
&lt;br /&gt;
			list.ID=&amp;quot;Brazil&amp;quot;;
&lt;br /&gt;
			list.Items.Add(&amp;quot;Brazil1&amp;quot;);
&lt;br /&gt;
			list.Items.Add(&amp;quot;Brazil2&amp;quot;);
&lt;br /&gt;
			list.Items.Add(&amp;quot;Brazil3&amp;quot;);
&lt;br /&gt;
			PlaceHolder1.Controls.Clear();  
&lt;br /&gt;
			PlaceHolder1.Controls.Add(list);
&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
		private void Button3_Click(object sender, System.EventArgs e)
&lt;br /&gt;
		{
&lt;br /&gt;
			//Button click handler to indicate we want to create a DDL for Brazil
&lt;br /&gt;
			if(!ShouldCreateBrazilDDL)
&lt;br /&gt;
			{
&lt;br /&gt;
				CreateBrazil();
&lt;br /&gt;
				ShouldCreateUsaDDL=false;
&lt;br /&gt;
				ShouldCreateBrazilDDL = true;
&lt;br /&gt;
			}
&lt;br /&gt;
		}
&lt;br /&gt;

&lt;br /&gt;

&lt;br /&gt;
&lt;/pre&gt;
&lt;br /&gt;

&lt;br /&gt;
Note that it assumes you to have two buttons on Page (and a PlaceHolder) with which you control what you want to be visible (which DDL).</description></item><item><title>create dropdownlist in runtime with event to create another dropdown.</title><link>http://forums.asp.net/thread/686293.aspx</link><pubDate>Wed, 08 Sep 2004 09:00:21 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:686293</guid><dc:creator>nu_ange</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/686293.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=158&amp;PostID=686293</wfw:commentRss><description>I have a dropdownlist which will call class to add another dropdownlist into placeholder of the page as SelectIndexChange event raised.
&lt;br /&gt;
The problem is 
&lt;br /&gt;
I want the new dropdownlist to be able to add another dropdownlist on SelectIndexChange event raised too and the new one should have this event as well. Then when user select dropdownlist it will always create a new one.
&lt;br /&gt;

&lt;br /&gt;
Anybody got an idea ?? 
&lt;br /&gt;</description></item></channel></rss>