Passing data to usercontrol (URGENT)

A

Anonymous

Hello,

I am loading a usercontrol with the LoadControl method
and need to pass some data to the property of that
control. How can I do that?

THanks
 
K

Karl Seguin

Anonymous:
Check out: http://openmymind.net/communication/index.html for a detailed
explanation of how to best get a page and its user controls to chat...but,
my guess is that you have somethin glike:

dim control as Control = Page.LoadControl("someThing.ascx")
SomePlaceHolder.Controls.Add(control)

if you have a public property that you want to set, you must cast the
control to the actual class someThing.ascx is, for example:

dim control as SomeThing = Ctype(Page.LoadControl("someThing.ascx"))
control.SomeValue = xxx 'this will work now
SomePlaceHodler.Controls.Add(control)


this assumes that your user control looks a bit like:

public class SomeThing
inherits UserControl

public property SomeValue() as String
get ... end get
set ... end set

...
end class

Hope this helps,
Karl
 
A

Anonymous

Ok, that works so far. But here is the real problem. I
have a datagrid. In the datagrid I load a user control
which contains another datagrid. Its like a nested grid.
When the user presses the + button then it collapses the
content and loads the usercontrol. BUT if he then presses
the + of the second row, then the first row (which was
expanded/open) closes automatically. BUT I want that row
to stay open, until I press the - sign. This is really
URGENT.
 
A

Anonymous

I already did that and I would like to stick with my
approach. I have already invested some time in his control
and it doesnt work for me. Please advise.
 
R

Roy

Anonymous... I would love you forever if you would post your code. :)
I'm working on something similar.
 
R

Roy

Or, if you're concerned because of copywrite purposes... ;P ...please
check out my post: Simple UserControl Question: why won't this work?
I suspect a small nudge from you could answer my question. :)
 

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
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top