DataGrid Custom Child Control Problem

G

Glenn Owens

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
 
G

Glenn Owens

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
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top