Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataGrid Custom Child Control Problem

Thread Tools

DataGrid Custom Child Control Problem

Glenn Owens
Posts: n/a
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.

Reply With Quote
Glenn Owens
Posts: n/a
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

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

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

AddHandler wc.DataBinding, AddressOf OnDataBinding

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

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

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to manage child control state for Custom Web Control? ASP .Net 0 10-19-2006 03:26 AM
Parent/Child relations - Trying to access child control for save ASP .Net Datagrid Control 0 04-15-2005 12:50 PM
Placeholder child of child control event problem. caldera ASP .Net Building Controls 1 05-28-2004 07:56 AM
How do I: Main thread spawn child threads, which child processes...control those child processes? Jeff Rodriguez C Programming 23 12-09-2003 11:06 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM