C
Conawapa11
I'm having trouble figuring this problem out and every example out
there deals with simple objects within a custom collection. Take this
example:
public class ComplexClass
{
private int id;
private InnerClass anotherOne;
public int ID
{
get { return id; }
}
public InnerClass AnotherOne
{
get { return anotherOne; }
}
}
public class InnerClass
{
private int id;
private string name;
public int ID
{
get { return id; }
}
public string Name
{
get { return name; }
}
}
then I have a
public class ComplexCustomCollection : CollectionBase
that contains a list of ComplexClass objects.
Now in my Custom Control, I have a DataGrid that I want to bind to
this ComplexCustomCollection.
When creating columns, I have something like:
BoundColumn column = new BoundColumn();
column.DataField = "ID";
column.HeaderText = "ID #";
myGrid.Columns.Add(column);
column = new BoundColumn();
column.DataField = "AnotherOne.Name"; // just a guess
column.HeaderText = "Another Name";
myGrid.Columns.Add(column);
myGrid.DataSource = myComplexCustomCollection;
myGrid.DataBind();
Which, when ran results in:
A field or property with the name 'AnotherOne.Name' was not found on
the selected datasource.
How can I bind to that inner class's properties?
Any help would be much appreciated. Thanks in advance...
there deals with simple objects within a custom collection. Take this
example:
public class ComplexClass
{
private int id;
private InnerClass anotherOne;
public int ID
{
get { return id; }
}
public InnerClass AnotherOne
{
get { return anotherOne; }
}
}
public class InnerClass
{
private int id;
private string name;
public int ID
{
get { return id; }
}
public string Name
{
get { return name; }
}
}
then I have a
public class ComplexCustomCollection : CollectionBase
that contains a list of ComplexClass objects.
Now in my Custom Control, I have a DataGrid that I want to bind to
this ComplexCustomCollection.
When creating columns, I have something like:
BoundColumn column = new BoundColumn();
column.DataField = "ID";
column.HeaderText = "ID #";
myGrid.Columns.Add(column);
column = new BoundColumn();
column.DataField = "AnotherOne.Name"; // just a guess
column.HeaderText = "Another Name";
myGrid.Columns.Add(column);
myGrid.DataSource = myComplexCustomCollection;
myGrid.DataBind();
Which, when ran results in:
A field or property with the name 'AnotherOne.Name' was not found on
the selected datasource.
How can I bind to that inner class's properties?
Any help would be much appreciated. Thanks in advance...