Complex data binding question, binding child objects of a custom collection.

J

JcFx

I have a custom collection of objects, each of which includes a child
object called MyUserOpener. In declarative binding, I can bind this
property to a label in a template control with the following syntax:

<%# DataBinder.Eval(CType(Container.DataItem.MyUserOpener,
AAA_Business.AAA_User), ("AAA_User__UserName"))%>

So far so good, this works fine.


I'm now trying to generate this datagrid dynamically incode. I'm using
reflection to inspect the properties of an object and generating a
column for each property, then binding the custom collection to the
grid, so my code looks something like this:

For Each ObjProperty As PropertyInfo In ObjProperties
Dim PropName As String = ObjProperty.Name.ToString()
Dim DataColumn As New BoundColumn
DataColumn.HeaderText = PropName.Substring(TableName.Length +
2).Replace("_", " ")
DataColumn.DataField = PropName
Me.m_grid.Columns.Add(DataColumn)
End If
Next

This works perfectly to generate bound columns for the simple
properties of my object, but I'm stumped trying to generate a column
for the complex binding to the child property. I understand how to
generate the template column but I can't figure out how to translate
the DataBinder.eval databinding statement to replicate the complex
binging in code behind.

Can anyone help ?

Many thanks in advance for any replies.
 

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

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top