CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 9/8/2004 9:00:21 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 42 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
nu_ange
Asp.Net User
create dropdownlist in runtime with event to create another dropdown.9/8/2004 9:00:21 AM

0/0

I have a dropdownlist which will call class to add another dropdownlist into placeholder of the page as SelectIndexChange event raised.
The problem is
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.

Anybody got an idea ??
joteke
Asp.Net User
Re: create dropdownlist in runtime with event to create another dropdown.9/11/2004 6:49:25 AM

0/0

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.


private void Page_Load(object sender, System.EventArgs e)
{
if(ShouldCreateUsaDDL)
{
CreateUSA();
}

if(ShouldCreateBrazilDDL)
{
CreateBrazil();
}
}


//Button click handler to indicate we want to create a DDL for USA
private void Button1_Click(object sender, System.EventArgs e)
{
if(!ShouldCreateUsaDDL)
{
CreateUSA();
ShouldCreateUsaDDL=true;
ShouldCreateBrazilDDL = false;
}


}

public bool ShouldCreateUsaDDL
{
get
{
object obj=ViewState["ShouldCreateUsaDDL"];
return (obj==null)? false : (bool)obj;
}
set
{
ViewState["ShouldCreateUsaDDL"]=value;
}
}


public bool ShouldCreateBrazilDDL
{
get
{
object obj=ViewState["ShouldCreateBrazilDDL"];
return (obj==null)? false : (bool)obj;
}
set
{
ViewState["ShouldCreateBrazilDDL"]=value;
}
}

private void CreateUSA()
{
DropDownList list=new DropDownList();
list.ID="USA";
list.Items.Add("Tallahassee");
list.Items.Add("Tennessee");
list.Items.Add("Washington");
PlaceHolder1.Controls.Clear();
PlaceHolder1.Controls.Add(list);
}

private void CreateBrazil()
{
DropDownList list=new DropDownList();
list.ID="Brazil";
list.Items.Add("Brazil1");
list.Items.Add("Brazil2");
list.Items.Add("Brazil3");
PlaceHolder1.Controls.Clear();
PlaceHolder1.Controls.Add(list);
}


private void Button3_Click(object sender, System.EventArgs e)
{
//Button click handler to indicate we want to create a DDL for Brazil
if(!ShouldCreateBrazilDDL)
{
CreateBrazil();
ShouldCreateUsaDDL=false;
ShouldCreateBrazilDDL = true;
}
}




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).
Thanks,

Teemu Keiski
Finland, EU
llangleyben
Asp.Net User
Re: create dropdownlist in runtime with event to create another dropdown.9/11/2004 7:39:09 PM

0/0

Read this article.
Leon Langleyben

MCSD, ASP.NET MVP

Blog
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Visual Basic 2005 Programmer's Reference Authors: Rod Stephens, Pages: 1022, Published: 2005
Access 2002: The Complete Reference Authors: Virginia Andersen, Pages: 1220, Published: -1
ASP.NET 2.0 Cookbook Authors: Michael A. Kittel, Geoffrey T. Leblond, Pages: 989, Published: 2005
A User's Guide to the Technical Training Schoolhouse Model Authors: Thomas Manacapilli, Bart Bennett, United States Air Force. Air Education and Training Command, Project Air Force (U.S.), Rand Corporation, Pages: 79, Published: 2006
MCSD in a Nutshell: The Visual Basic Exams Authors: James D. Foxall, Pages: 632, Published: 2000
Microsoft Visual Basic 6.0 Developer's Workshop: Developer's Workshop Authors: John Clark Craig, Jeff Webb, Pages: 804, Published: 1998
Microsoft Windows Server 2008: Implementation and Administration Authors: Barrie Sosinsky, Pages: 356, Published: 2008

Web:
create dropdownlist in runtime with event to create another ... create dropdownlist in runtime with event to create another dropdown. Last post 09-11-2004 3:39 PM by llangleyben. 2 replies. Sort Posts: ...
create dropdownlist in runtime with event to creat - technical ... I have a dropdownlist which will call class to add another dropdownlist into placeholder of the page ... create dropdownlist in runtime with event to creat ...
AMIS Technology blog » Blog Archive » Dynamic switch between ... Jan 1, 2007 ... Dynamic switch between radiobuttons and dropdownlist - create a new ... either radio buttons or drop downlist may be invalid at run time. ...
2nd Post: Problem adding events to controls created at run-time ... The code to create the controls is working fine but now I need to add events to the newly created DropDownList controls. I need to add the ...
p2p.wrox.com: Archives - aspx archive All I need to do, is create a dropdownlist at runtime which I can connect to ... something like this (I'm assuming you've linked an event to handle updates, ...
Drop down list inside a DBGrid - part 1 (page 2/2) Drop down list inside a DBGrid - part 1. Here's how to place a drop down pick list into a DBGrid. Create visually more attractive user interfaces for ...
CodeProject: AJAX DropDownList. Free source code and programming help Those demanding users are my motivation to create this custom control. ..... How can I change the value of a dropdownlist that depends on another ...
Kristof De Causemaeker - Information Worker: Switch view when drop ... So we have to force the OnContextChange event by changing the focus from the drop down list to another field through code. ...
Sorry another DropdownList & Datagrid Problem - PLS HELP ... In order to populate the dropdownlist you could create an array in the page load event of all the available colors and set the datasource of ...
The Community for Skyway Users, Developers, and Contributors ... I am trying to figure out how to use the drop down list. .... Create another new jsp page that just has a Skyway Drop Down menu on it and nothing else, ...




Search This Site:










[1.2] - links of interest

create a class library to manage users profile (to be used on user admin page)

losing input from controls on postback

please help.... i can't find this anywhere! ... form application

tiny enhancement request

stack trace numbers..

how do you redirect url from secure (https:) login to unsecure (http:) with returnurl ??????

can't connect to sql server in windows service

problem in horizontal menu

dnn 3.2 on sql 2005 with visual studio 2005

databing textbox c#

sigmapro draconis 5.0 beta testers needed

asp.net & ssl hosting?? webhost4life = no

dotnetedit

control placement of button

ide not showing custom control in vs 2005

usersonline and dnn 1.0.10

send a mail which contains a welcome letter or a newsletter to a new user

jscript, moving from client-side to server-side (.net)

security question - how dnn prevents direct access to edit via a url/id?

content

enable shared scope for admin in web part

error after installation

adding countries and regions to the lists on the register page

how do i get this to work? please help!

please help :: access to the path is denied !!!

installing asp to asp.net migration assistant

passing objects

how to use "page base type" and "user control base type"

customize membership and roles?

 
All Times Are GMT