473,408 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Getting data to a user control?

Hi,

Files related:
1. Search.aspx <- contains a <mycontrol:simplepaging runat=server>
2. Search.aspx.cs <- codebehind
3. SimplePaging.cs

How do I send data from the codebehind into the user control and visa versa?

Thanks a lot for any reply.
Anders
Nov 18 '05 #1
7 1055
Okay, now think about ASP.Net as an object-oriented technology, and the
answer should become obvious. You don't want to send data from one FILE to
another. You want to send data from one OBJECT to another. Now, how do you
do that? You either expose a property or a method that can accept data in
one class, and pass it from the other via that interface.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"news.microsoft.com" <as**@os.com> wrote in message
news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi,

Files related:
1. Search.aspx <- contains a <mycontrol:simplepaging runat=server>
2. Search.aspx.cs <- codebehind
3. SimplePaging.cs

How do I send data from the codebehind into the user control and visa versa?
Thanks a lot for any reply.
Anders

Nov 18 '05 #2
Yes I could make a property value in simplepaging called MyDataTable but
still how do I fill it?

I though of doing a Control simplePaging = Page.FindControl("SimplePaging");
but how do I fill it with the datatable?

Thanks

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Okay, now think about ASP.Net as an object-oriented technology, and the
answer should become obvious. You don't want to send data from one FILE to
another. You want to send data from one OBJECT to another. Now, how do you
do that? You either expose a property or a method that can accept data in
one class, and pass it from the other via that interface.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"news.microsoft.com" <as**@os.com> wrote in message
news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi,

Files related:
1. Search.aspx <- contains a <mycontrol:simplepaging runat=server>
2. Search.aspx.cs <- codebehind
3. SimplePaging.cs

How do I send data from the codebehind into the user control and visa

versa?

Thanks a lot for any reply.
Anders


Nov 18 '05 #3
Once you have a handle on the Control, just cast it as the type it is, and
reference the property.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Anders" <mo****@gmail.com> wrote in message
news:#M**************@tk2msftngp13.phx.gbl...
Yes I could make a property value in simplepaging called MyDataTable but
still how do I fill it?

I though of doing a Control simplePaging = Page.FindControl("SimplePaging"); but how do I fill it with the datatable?

Thanks

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Okay, now think about ASP.Net as an object-oriented technology, and the
answer should become obvious. You don't want to send data from one FILE to another. You want to send data from one OBJECT to another. Now, how do you do that? You either expose a property or a method that can accept data in one class, and pass it from the other via that interface.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"news.microsoft.com" <as**@os.com> wrote in message
news:e2**************@TK2MSFTNGP12.phx.gbl...
Hi,

Files related:
1. Search.aspx <- contains a <mycontrol:simplepaging runat=server>
2. Search.aspx.cs <- codebehind
3. SimplePaging.cs

How do I send data from the codebehind into the user control and visa

versa?

Thanks a lot for any reply.
Anders



Nov 18 '05 #4
Thanks Kevin, you give us food for thought :)

I was planning to have the simplepaging.cs return the DataTable to the
codebehind file so that it can databind it. But is that good programming?

cheers,
Anders

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eF**************@TK2MSFTNGP11.phx.gbl...
Once you have a handle on the Control, just cast it as the type it is, and
reference the property.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Anders" <mo****@gmail.com> wrote in message
news:#M**************@tk2msftngp13.phx.gbl...
Yes I could make a property value in simplepaging called MyDataTable but
still how do I fill it?

I though of doing a Control simplePaging = Page.FindControl("SimplePaging");
but how do I fill it with the datatable?

Thanks

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Okay, now think about ASP.Net as an object-oriented technology, and the answer should become obvious. You don't want to send data from one FILE to
another. You want to send data from one OBJECT to another. Now, how do you do that? You either expose a property or a method that can accept data in one class, and pass it from the other via that interface.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"news.microsoft.com" <as**@os.com> wrote in message
news:e2**************@TK2MSFTNGP12.phx.gbl...
> Hi,
>
> Files related:
> 1. Search.aspx <- contains a <mycontrol:simplepaging runat=server>
> 2. Search.aspx.cs <- codebehind
> 3. SimplePaging.cs
>
> How do I send data from the codebehind into the user control and

visa versa?
>
> Thanks a lot for any reply.
> Anders
>
>



Nov 18 '05 #5
Hi Anders,

I can't answer that question. I don't know enough about your app to be able
to.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Anders" <mo****@gmail.com> wrote in message
news:#p*************@TK2MSFTNGP09.phx.gbl...
Thanks Kevin, you give us food for thought :)

I was planning to have the simplepaging.cs return the DataTable to the
codebehind file so that it can databind it. But is that good programming?

cheers,
Anders

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:eF**************@TK2MSFTNGP11.phx.gbl...
Once you have a handle on the Control, just cast it as the type it is, and
reference the property.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Anders" <mo****@gmail.com> wrote in message
news:#M**************@tk2msftngp13.phx.gbl...
Yes I could make a property value in simplepaging called MyDataTable but still how do I fill it?

I though of doing a Control simplePaging =

Page.FindControl("SimplePaging");
but how do I fill it with the datatable?

Thanks

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Okay, now think about ASP.Net as an object-oriented technology, and the > answer should become obvious. You don't want to send data from one FILE
to
> another. You want to send data from one OBJECT to another. Now, how

do you
> do that? You either expose a property or a method that can accept
data in
> one class, and pass it from the other via that interface.
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "news.microsoft.com" <as**@os.com> wrote in message
> news:e2**************@TK2MSFTNGP12.phx.gbl...
> > Hi,
> >
> > Files related:
> > 1. Search.aspx <- contains a <mycontrol:simplepaging runat=server>
> > 2. Search.aspx.cs <- codebehind
> > 3. SimplePaging.cs
> >
> > How do I send data from the codebehind into the user control and

visa > versa?
> >
> > Thanks a lot for any reply.
> > Anders
> >
> >
>
>



Nov 18 '05 #6
Thanks for all the help so far Kevin. Im beginning to understand the OOP.

I am overriding the OnInit event to do the Page.LoadControl of the ascx
file. Is that an appropriate way?

I am inheriting WebControl.

best,
Anders

"Kevin Spencer" <ks******@takempis.com> wrote in message news:%23
Nov 18 '05 #7
Hi Anders,

It may or may not be appropriate, depending on the circumstances. If it is
working, I would suspect that it's okay. You can read all about the Control
Execution LifeCycle at:

http://msdn.microsoft.com/library/de...nLifecycle.asp

This reference is applicable to ALL Server Controls, including
System.Web.UI.Page, and is quite handy when deciding when to perform certain
types of operations.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Anders" <mo****@gmail.com> wrote in message
news:OY**************@TK2MSFTNGP11.phx.gbl...
Thanks for all the help so far Kevin. Im beginning to understand the OOP.

I am overriding the OnInit event to do the Page.LoadControl of the ascx
file. Is that an appropriate way?

I am inheriting WebControl.

best,
Anders

"Kevin Spencer" <ks******@takempis.com> wrote in message news:%23

Nov 18 '05 #8

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

Similar topics

15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
2
by: Duwayne | last post by:
I am having lots of trouble with one of my user controls (ascx) not automatically loading postback data. An image on the aspx page starts the postback and the parent has no problem loading it's own...
10
by: darrel | last post by:
I have this structure: mypage.aspx (class = mypage) myusercontro.ascx On the mypage.aspx I can declare a variable: animal = "monkey" I can read this from the UC by simply doing this:...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
8
by: MattB | last post by:
I have a asp.net 1.1/vb application that has a page with a bunch of dynamically added User Controls. When I add the controls, I set the UserControl.EnableViewState to true. For all my controls...
3
by: Sridhar | last post by:
Hi, I am having a trivial problem which is not that important but I would like to know if I am missing something. I have created a user control. When I drag the user control into one of the web...
1
by: Alec MacLean | last post by:
Hi, Outline of problem: I've built a set of user controls that are used to output questions for a survey and gather the responses using simple radio buttons. I'm adding an optional textbox...
1
by: Developer | last post by:
Dear Group Member, I am sorry if I have posted this query in wrong group, but since this is connected with ASPO.NET2.0, thought of posting here. I am doing a very simple program where I am...
0
by: aboutjav.com | last post by:
Hi, I need some help. I am getting this error after I complete the asp.net register control and click on the continue button. It crashed when it tries to get it calls this Profile property ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.