Hello,
It seems that the 2.0 web part framework works great if the web parts can be defined at design time. I'm having a heck of a time getting them to work dynamically at runtime.
My goal: I want to develop a generic page that dynamically loads web parts based on metadata stored in the database. This metadata allows the administrator to create digital dashboards on the fly by specifying things like # of columns, web part controls, and data sources for the databound web parts.
Since this page will be dynamically created, I have only defined a WebPartManager instance at design time (the zones and web parts are added at runtime). I have gotten this to work somewhat. I can get the web parts to display on the first page load. If the user tries to personalize the web parts, some crazy things start happening. Here are some specific questions:
- When I initially create a web part, I assign it a unique ID (e.g. WebPart1). When the control is rendered, its ID has been changed to something else (e.g. wp984699763). Why does this happen? This is causing me fits because I want to be able to get a handle on the web part that I originally created.
- Since the dynamically-assigned ID of the web part changes with each page load, how are the user's personalization settings saved for that particular web part? For example, if the user minimizes the web part, how does the web part framework know to minimize the web part on subsequent page loads if the ID is constantly changing?
My guess is that many of my problems stem from the fact that the web part IDs are being automatically assigned to new values on every page load. Is there a way to stop this and use the IDs that I assign? Should I even bother with spending more time on this? I'm not sure if the web part framework was designed to allow this sort of flexibility.
Thanks,
Jason