DataBindings in child controls (NullReferenceException)

L

LucaP

Hi. I'm developing a sample custom web control that have a collection
property.
Here is some code:

[
ToolboxData("<{0}:MyWebControl runat=server></{0}:MyWebControl>"),
Designer(typeof(MyControlDesigner)),
ControlBuilder(typeof(MyControlBuilder)),
ParseChildren(false), PersistChildren(false)]
public class MyWebControl
{ ...

private ItemCollection items = new ItemCollection();

[Bindable(true),
Description("Collection of items"), NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty),
DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ItemCollection Items
{
get
{
return items;
}
}

....}

The following html code is generated by VS.NET:

<html>
....
<MyCC:MyWebControl id="MyWebControl1" runat="server">
<Items>
<cc:Item ID="item1"></cc:Item>
<cc:Item ID="item2"></cc:Item>
<cc:Item ID="item3"></cc:Item>
</Items>
</MyCC:MyWebControl>
....
</html>

It's all ok at runtime. The html is ok too.
My problem is that at designtime the (DataBindings) property of the Item
controls is not available. If i try to click on the "..." i receive a
NullReferenceException! Why?
I have the same exception with every type of collection...
Is there a way to solve this problem?!
Thanx a lot.
Bye.
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top