R
Rachel Koktava
Hi
I'm having difficulty bind a collection of custom objects to a
datagrid. For reasons that I'll explain shortly I can't use
Collectionbase, so have instead implemented a custom collection with
the interfaces IList, ICollection and IEnumerable.
This class works find for indexing or iterating (foreach etc), but
when set as the datasource for a web datagrid control it throws an
exception on callinging the datagrids DataBind() method:
[ArgumentNullException: Value cannot be null.
Parameter name: component]
System.ComponentModel.TypeDescriptor.GetProperties(Object
component, Boolean noCustomTypeDesc) +173
System.ComponentModel.TypeDescriptor.GetProperties(Object
component) +7
System.Web.UI.WebControls.BoundColumn.OnDataBindColumn(Object
sender, EventArgs e) +95
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex,
Int32 dataSourceIndex, ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollection rows,
PagedDataSource pagedDataSource) +169
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource) +1408
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
+49
System.Web.UI.WebControls.BaseDataList.DataBind() +23
ASP.test7_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in C:\Inetpub\wwwroot\test\test7.aspx:85
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1929
I'm assuming (but can't be sure) that this error message is because
the datagrid doesn't know how to bind the custom collection or objects
to its required datastructure. If this is the case I'd appreciate some
advice on how to do this.
If not, then any other help/explanation would be much appreciated.
To elaborate further, the data in question is being retrieved from an
Object Database. Object databases can store the objects in their own
"collections" called sets which provide their own iterators, search,
indexing etcetera. Hence I do not wish to use Collectionbase since
this would require copying the OODB sets into the innerList (the sets
are rather large). Really all I want is a wrapper (and adapter
pattern) that presents these sets as a collection that can be bound to
the datagrid, eg, implementing a custome collection using ICollection,
IList and IEnumerable, but calling the OODB methods for iteration,
indexing etc.
And it must be capably of binding to a datagrid control.
One more thing. At present the implementation is in Managed C++,
(because the OODB API is C++), but solutions in C# are acceptable if
there is no Managed C++ approach that will work.
thanks in advance
Rachel
I'm having difficulty bind a collection of custom objects to a
datagrid. For reasons that I'll explain shortly I can't use
Collectionbase, so have instead implemented a custom collection with
the interfaces IList, ICollection and IEnumerable.
This class works find for indexing or iterating (foreach etc), but
when set as the datasource for a web datagrid control it throws an
exception on callinging the datagrids DataBind() method:
[ArgumentNullException: Value cannot be null.
Parameter name: component]
System.ComponentModel.TypeDescriptor.GetProperties(Object
component, Boolean noCustomTypeDesc) +173
System.ComponentModel.TypeDescriptor.GetProperties(Object
component) +7
System.Web.UI.WebControls.BoundColumn.OnDataBindColumn(Object
sender, EventArgs e) +95
System.Web.UI.Control.OnDataBinding(EventArgs e) +66
System.Web.UI.Control.DataBind() +26
System.Web.UI.Control.DataBind() +86
System.Web.UI.WebControls.DataGrid.CreateItem(Int32 itemIndex,
Int32 dataSourceIndex, ListItemType itemType, Boolean dataBind, Object
dataItem, DataGridColumn[] columns, TableRowCollection rows,
PagedDataSource pagedDataSource) +169
System.Web.UI.WebControls.DataGrid.CreateControlHierarchy(Boolean
useDataSource) +1408
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e)
+49
System.Web.UI.WebControls.BaseDataList.DataBind() +23
ASP.test7_aspx.__Render__control1(HtmlTextWriter __output, Control
parameterContainer) in C:\Inetpub\wwwroot\test\test7.aspx:85
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +27
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1929
I'm assuming (but can't be sure) that this error message is because
the datagrid doesn't know how to bind the custom collection or objects
to its required datastructure. If this is the case I'd appreciate some
advice on how to do this.
If not, then any other help/explanation would be much appreciated.
To elaborate further, the data in question is being retrieved from an
Object Database. Object databases can store the objects in their own
"collections" called sets which provide their own iterators, search,
indexing etcetera. Hence I do not wish to use Collectionbase since
this would require copying the OODB sets into the innerList (the sets
are rather large). Really all I want is a wrapper (and adapter
pattern) that presents these sets as a collection that can be bound to
the datagrid, eg, implementing a custome collection using ICollection,
IList and IEnumerable, but calling the OODB methods for iteration,
indexing etc.
And it must be capably of binding to a datagrid control.
One more thing. At present the implementation is in Managed C++,
(because the OODB API is C++), but solutions in C# are acceptable if
there is no Managed C++ approach that will work.
thanks in advance
Rachel