Assuming that there is some good reason for using a database to dynamically
load controls, I think you've gotten off on the wrong foot. Why are you
storing strings in the database? The names of namespaces and classes is
useful to us humans, but not particularly to computers. It would be more
efficient to store integers in the database. Assuming (again) that you know
what you're storing in the database, you could create Enumerations that
represent different namespaces and classes, and store the enumerated values
in the database. From there it's a simple matter of identifying the Control
to load via its enumerated value.
You would need some sort of mechanism to identify the Controls whose names
are stored in the database anyway. You could do it with Reflection, but that
would be expensive, and I see no benefit gained from it.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.
<je************@yahoo.se> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi there,
I have some webcontrols that i want to add dynamically on a page. I
have stored the path / namespace in database (ex
MyNameSpace.WebControls.Control1) to the class/webcontrol.
Lets say i have a column in database that looks like this.
PageID (int) Webcontrol (varchar)
1 MyNameSpace.WebControls.Control1
1 MyNameSpace.WebControls.Control2
Then i want to add the controls dynamically on the page, anyone know
how to do this ?
I guess i have to create a instance of the webcontrol and the add it
with Controls.add() . But how do i create the instance and add it
dynamically from a string?
Hope anyone can help me with this, some expert out there ?? :)
Thanks
Jesper