J
Jiho Han
I have a control that inherits from WebControl.
In it, I have a property of a collection type. Basically it's similar to
how DataGrid works in design-time.
See the code below. Basically, when I add a DataGridColumn through the
collection editor in the designer, the correct tags are persisted inside my
control as I can see them when I switch to the HTML view. However, the
opposite is not true - when I add the tags manually in the HTML view and
switch to the design view, the control reports error "Columns could not be
initialized"?
<customataGrid>
<Columns>
<customataGridColumn></customataGridColumn>
</Columns>
</custom:/DataGrid>
(the above generates an error if edited in the HTML view)
Anyone know what's going on? Am I missing some attributes somewhere?
// ParseChildren(true) defined in WebControl
public class DataGrid : WebControl, INamingContainer
{
private DataGridColumnCollection _columns;
...
[
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public DataGridColumnCollection Columns
{
get
{
if (_columns == null)
return _columns = new DataGridColumnCollection();
return _columns;
}
}
}
public class DataGridColumnCollection : CollectionBase
{
public DataGridColumn this[int index]
{
get
{
return (DataGridColumn) List[index];
}
}
}
public class DataGridColumn
{
public DataGridColumn()
{
}
}
In it, I have a property of a collection type. Basically it's similar to
how DataGrid works in design-time.
See the code below. Basically, when I add a DataGridColumn through the
collection editor in the designer, the correct tags are persisted inside my
control as I can see them when I switch to the HTML view. However, the
opposite is not true - when I add the tags manually in the HTML view and
switch to the design view, the control reports error "Columns could not be
initialized"?
<customataGrid>
<Columns>
<customataGridColumn></customataGridColumn>
</Columns>
</custom:/DataGrid>
(the above generates an error if edited in the HTML view)
Anyone know what's going on? Am I missing some attributes somewhere?
// ParseChildren(true) defined in WebControl
public class DataGrid : WebControl, INamingContainer
{
private DataGridColumnCollection _columns;
...
[
NotifyParentProperty(true),
PersistenceMode(PersistenceMode.InnerProperty)
]
public DataGridColumnCollection Columns
{
get
{
if (_columns == null)
return _columns = new DataGridColumnCollection();
return _columns;
}
}
}
public class DataGridColumnCollection : CollectionBase
{
public DataGridColumn this[int index]
{
get
{
return (DataGridColumn) List[index];
}
}
}
public class DataGridColumn
{
public DataGridColumn()
{
}
}