473,508 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing data to usercontrol (URGENT)

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
Nov 19 '05 #1
6 1968
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
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Anonymous" <an*******@discussions.microsoft.com> wrote in message
news:21****************************@phx.gbl...
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

Nov 19 '05 #2
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.

-----Original Message-----
Anonymous:
Check out: http://openmymind.net/communication/index.html for a detailedexplanation 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 thecontrol 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
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Anonymous" <an*******@discussions.microsoft.com> wrote in messagenews:21****************************@phx.gbl...
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

.

Nov 19 '05 #3
Ahh..the full question.

This is certainly doable, but I'd recommend you look at the wonderful (and
wonderfully free) control by Denis Bauer called HierarGrid, which you can
download (and demo) at :
http://www.denisbauer.com/ASPNETCont...ierarGrid.aspx

You can also get the source code which should show you how he did it...
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Anonymous" <an*******@discussions.microsoft.com> wrote in message
news:0c****************************@phx.gbl...
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.

-----Original Message-----
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
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Anonymous" <an*******@discussions.microsoft.com> wrote

in message
news:21****************************@phx.gbl...
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

.

Nov 19 '05 #4
Roy
Anonymous... I would love you forever if you would post your code. :)
I'm working on something similar.

Nov 19 '05 #5
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.

-----Original Message-----
Ahh..the full question.

This is certainly doable, but I'd recommend you look at the wonderful (andwonderfully free) control by Denis Bauer called HierarGrid, which you candownload (and demo) at :
http://www.denisbauer.com/ASPNETCont...ierarGrid.aspx

You can also get the source code which should show you how he did it...Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Anonymous" <an*******@discussions.microsoft.com> wrote in messagenews:0c****************************@phx.gbl...
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.

>-----Original Message-----
>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
>
>
>--
>MY ASP.Net tutorials
>http://www.openmymind.net/
>
>
>"Anonymous" <an*******@discussions.microsoft.com> wrote

in message
>news:21****************************@phx.gbl...
>> 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
>
>
>.
>

.

Nov 19 '05 #6
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. :)

Nov 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1748
by: Peter | last post by:
I have an Usercontrol on a WebForm, on this Usercontrol is a button, I want to save data that's residing on the WebForm when user clicks on the button that's on the UserControl. How do I call a...
5
1288
by: Tarun Mistry | last post by:
Hi all, is it possible to update a usercontrol before it is rendered? In my scenario I have a Page with a usercontrol on it. When a button is clicked on the Page, I want to update the...
2
3375
by: gerry | last post by:
based on MSPress's ASP.NET 2.0 Applications Advaced Topics ( Table 12-3 p.472 ), and most events should be automatically wired up when @Control AutoEventWireup="true". ie. Page_InitComplete() {}...
6
2748
by: Rolf Welskes | last post by:
Hello, I want to partial cache by using a UserControl. Now I have a file dependency. In msdn I see it is not possible to do it the same way as in a page. The only information is to create a...
5
19632
by: Blue | last post by:
We have a custom word processing type editor built with C# and .NET 2.0 and we need to support typing in languages other than English. I want to be able to use the Windows IME to enter in text...
14
3181
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
Hi. I have created a UserControl ("MyUC"). I've put a bunch of instances of that control on a Page ("Defaul.aspx"). The control works fine. Now, I want to be able to use "FindControl()" from...
9
1554
by: Chris | last post by:
Ok, so I have this sub I wrote, and I create a new instance of a UserControl: ctrlAPs tempctrl = new ctrlAPs(); Now, I would like to be able to use this sub I wrote for more than one...
8
2075
by: =?Utf-8?B?bWljaGFlbCBzb3JlbnM=?= | last post by:
I created a user control that handles certain keystrokes, e.g. Ctrl-C for cut, Ctrl-V for paste, plus other more specialized keystrokes. I want to list these in the menubar like any other menu...
2
2255
by: Joe | last post by:
Is it possible to inherit from a UserControl? If I try my user control class is not recognized. Thanks, Joe
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.