Link to home
Start Free TrialLog in
Avatar of pratikshahse
pratikshahse

asked on

Dynamically create controls in asp.net

I am trying to create a list box dynamically in my code. There is a condition that needs to be true in order for listbox to be created. Can someone tell me how I can create the list box and then populate it with an array that I already have.

I have my code below
If APrompt.HasLOV = True Then
   ' create a dynamic listbox over here
   ' loop through the array and populate the listbox
 else
    'create a dynamic textbox over here
end if

i do not have a codebehind file so everything is in my aspx page. also the above condition is being called multiple times so everytime a new listbox is created I need to give it a unique name. listbox1,listbox2,listbox3(i should be able to handle that part).

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of masterpass
masterpass
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pratikshahse
pratikshahse

ASKER

I had already tried thta.  but it does not show the list box on screen when I run the application
Have a placeholder

<asp:PlaceHolder ID="ph1' runat="server" />

now after creating the listbox

ph1.Controls.Add(lst);