DataGrid Custom Child Control Problem

Discussion in 'ASP .Net' started by Glenn Owens, Jul 7, 2004.

  1. Glenn Owens

    Glenn Owens Guest

    I have a Web DataGrid into which I've added a templatecolumn. Into the
    templatecolumn I've placed a progressbar custom control (which
    provides its rendering by overriding the Render method of the custom
    control). When the templatecolumn is added, to the DataGrid, I've also
    added a DataBinding event handler (addressof method) for the control
    (which is used to set the progressbar properties).

    When I run the web page (in debug) I get the DataBind event fired for
    the progrssbar on each successive row (DataGridItem) and, set some
    static property values (for testing). However, the progressbar render
    method is only called for the last row of the DataGrid (none of the
    previous progressbar controls even show up in the HTML).

    I would really appreciate any help/insight into this problem.

    tia
    Glenn
    Glenn Owens, Jul 7, 2004
    #1
    1. Advertising

  2. Glenn Owens

    Glenn Owens Guest

    OK, I found the "problem". It seems that I need to instantiate the
    control object, that is to be placed into the templatecolumn
    container, in the InstantiateIn method.

    So, I'm passing a control, which I've created in the aspx code-behind
    in response to an event in my DataGrid, into my TemplateColumnFactory
    class. The factory class figures out that it doesn't "know" the class
    type being passed in so it performs the following in the InstantiateIn
    method:

    If Not IsNothing(_ctl) Then
    Dim wc As System.Web.UI.Control = _
    DirectCast(ObjectLoader.LoadObject(_ctl.GetType),System.Web.UI.Control)

    ObjectLoader.DeepCopy(_ctl, DirectCast(wc, Object))

    AddHandler wc.DataBinding, AddressOf OnDataBinding

    container.Controls.Add(wc)
    End If

    This works great...

    =====================================
    =====================================

    Now, has anyone had any success at loading a System.Web.UI.WebControls
    - based object? When I try loading, ie a
    System.Web.UI.WebControls.Label I get the following message:

    File or assembly name System.Web, or one of its dependencies, was not
    found.

    I know that the assembly is referenced in the project so why can't it
    be located?

    Glenn
    Glenn Owens, Jul 8, 2004
    #2
    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. Jeff Rodriguez
    Replies:
    23
    Views:
    1,111
    David Schwartz
    Dec 9, 2003
  2. Replies:
    0
    Views:
    328
  3. Matt Sokol
    Replies:
    2
    Views:
    375
    Theo Tillotson
    Aug 7, 2003
  4. caldera

    Placeholder child of child control event problem.

    caldera, May 27, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    212
  5. Replies:
    0
    Views:
    206
Loading...

Share This Page