J
John Sewell
Wonder if anyone can point me in the right direction!!
Basically I have built an ASP.net (VB.net) user control to display
data and this is comprised of a set of user controls that display
parts of the page (header, body etc.)
The problem I have is that this works fine when I just have the
control on a normal page, but does not work when I try to dynamically
add them to a page so that I can show a set of document on the same
page.
The page control (call it ctlPage) has 2 controls on it (ctlHeader,
ctlBody).
I did have to add each control to the area
'#Region " Web Form Designer Generated Code "'
in order to reference them in code (so I can call the init method with
the ID of them to show)
So ctlPage has a public method "ShowData" which simply calls the
methods on the controls on the page with the ID passed in.
The problem is that when control is created dynamically I get an error
that the controls on ctlPage are not set when I try and call ShowData.
I get the error:
"Object reference not set to an instance of an object", the objects
dont seem to be created.
The call to create ctlPage dynamically is:
theNewItem = New ctlPage
newCell.Controls.Add(theNewItem)
theNewItem.ShowData(dsData.Tables(0).Rows(lngLoop)("ItemID"))
Does anyone have an idea what I have done wrong or I am not
initialising the control(s) correctly?
Many thanks,
John
Basically I have built an ASP.net (VB.net) user control to display
data and this is comprised of a set of user controls that display
parts of the page (header, body etc.)
The problem I have is that this works fine when I just have the
control on a normal page, but does not work when I try to dynamically
add them to a page so that I can show a set of document on the same
page.
The page control (call it ctlPage) has 2 controls on it (ctlHeader,
ctlBody).
I did have to add each control to the area
'#Region " Web Form Designer Generated Code "'
in order to reference them in code (so I can call the init method with
the ID of them to show)
So ctlPage has a public method "ShowData" which simply calls the
methods on the controls on the page with the ID passed in.
The problem is that when control is created dynamically I get an error
that the controls on ctlPage are not set when I try and call ShowData.
I get the error:
"Object reference not set to an instance of an object", the objects
dont seem to be created.
The call to create ctlPage dynamically is:
theNewItem = New ctlPage
newCell.Controls.Add(theNewItem)
theNewItem.ShowData(dsData.Tables(0).Rows(lngLoop)("ItemID"))
Does anyone have an idea what I have done wrong or I am not
initialising the control(s) correctly?
Many thanks,
John