Passing data to usercontrol (URGENT)

  • Thread starter Thread starter Anonymous
  • Start date Start date
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
 
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
 
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.
 
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.
 
Anonymous... I would love you forever if you would post your code. :)
I'm working on something similar.
 
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. :)
 
Back
Top