how to DataBinder.Eval to a subproperty's property

  • Thread starter Thread starter Eric Newton
  • Start date Start date
E

Eric Newton

Given databinding an array of System.Version types:

Given that "SomeObject" type has a Version property:

public class SomeObject
{
public Version Version { get; }
public string Description { get; }
}

and I want to bind a list of them to a datagrid.

SomeObject[] someObjectList; // populate this array with properly
instantiated SomeObject types.
DataGrid1.DataSource = someObjectList; // basically an array of "someobject"
DataGrid1.DataBind();

How does one utilize the DataBinder.Eval (and in asp.net v2.0, the Eval
method) to get to the SomeObject.Version.Major property?

I'm trying to get to the subproperty "Major" on the "Version" property.

aspx page fragment:
<asp:Repeater runat=server>
<ItemTemplate>
SomeObject.Version.Major=<%#
DataBinder.Eval(Container.DataItem,"Version.Major")%><br/>
SomeObject.Version.Minor=<%#
DataBinder.Eval(Container.DataItem,"Version.Minor")%><br/>
</ItemTemplate>
</asp:Repeater>

(Assuming ALL that other stuff is Syntax proper, and so forth)
 
Back
Top