Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi,
I have some UserControls named a1, a2, b1, b2... and I want to load one of them depending of the value of two variables. For example, var1 = a, var2 = 1 will load the UserControl named a1.
Is there a way of doing this? Some other approach?
A switch is not viable, because there will be like 200 different UserControls.
Thank you in advance.
Posted

1 solution

You can use the LoadControl[^] method for loading the controls. Generate the name of user controls by combining the variables.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900