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

Discussion in 'ASP .Net Datagrid Control' started by JcFx, Jun 1, 2005.

  1. JcFx

    JcFx Guest

    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.
    JcFx, Jun 1, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Conawapa11
    Replies:
    1
    Views:
    652
    Michael Tkachev
    Nov 14, 2003
  2. Christoph Boget

    Binding a data source to a collection of objects

    Christoph Boget, Aug 12, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    2,281
    =?Utf-8?B?QVNQIFlhYm9o?=
    Sep 20, 2004
  3. =?Utf-8?B?RGVtZXRyaQ==?=

    Binding child objects of a custom collection

    =?Utf-8?B?RGVtZXRyaQ==?=, Aug 31, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    590
    =?Utf-8?B?RGVtZXRyaQ==?=
    Sep 1, 2005
  4. Jeff Rodriguez
    Replies:
    23
    Views:
    1,116
    David Schwartz
    Dec 9, 2003
  5. Øyvind Isaksen
    Replies:
    1
    Views:
    966
    Øyvind Isaksen
    May 18, 2007
Loading...

Share This Page