how to DataBinder.Eval to a subproperty's property

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)
 
B

Brock Allen

I think you posted this elsewhere and I replied that DataBinder.Eval(Container.DataItem,
"Version.Major") should work. I just built a test and it works with System.Version.
 

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

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top