adding webparts during runtime. Problem !

T

ton

Hi,

I want to add a table to a form, within the table 3 rows, 3 columns (as a
default) and within each cell a webpart. This works ok:

For i = 1 To aantalY
r = New TableRow
For j = 1 To aantalX
c = New TableCell
c.BorderStyle = BorderStyle.Solid
c.BorderWidth = 1
c.Height = 100
c.BorderColor = Drawing.Color.Black
w = New WebPartZone
w.ID = "web" & i & "_" & j
If bNieuw Then
UC = New WebUserControl
UC.ID = "uc" & i & "_" & j
w.Controls.Add(UC) ''''''''' THIS LINE
receiveses the ERROR
End If

c.Controls.Add(w)
r.Cells.Add(c)
Next
Table1.Rows.Add(r)
Next


except that if bNieuw=True the usercontrol cannot be added. I receive

System.Web.HttpException was unhandled by user code
ErrorCode=-2147467259
Message="System.Web.UI.WebControls.WebParts.WebPartZone staat geen
onderliggende besturingselementen toe."
Source="System.Web"
StackTrace:
bij System.Web.UI.EmptyControlCollection.ThrowNotSupportedException()
bij System.Web.UI.EmptyControlCollection.Add(Control child)
bij _Default.CreateBasetable() in
C:\vb300\Web\CompassNET\Default.aspx.vb:regel 112
bij _Default.Page_Init(Object sender, EventArgs e) in
C:\vb300\Web\CompassNET\Default.aspx.vb:regel 49
bij System.Web.UI.Control.OnInit(EventArgs e)
bij System.Web.UI.Page.OnInit(EventArgs e)
bij System.Web.UI.Control.InitRecursive(Control namingContainer)
bij System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:



can anyone help her ?
Thanx


ton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top