473,408 Members | 1,722 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.

Repeater Contains Web User Control

Hi all

I have a repeater control containing a web user control within its'
item template field.

Is it possible to pass through a data field into the web user control,
such that this is used when rendering the web user control.

I have exposed a parameter of the web user control and attempted to
pass in the parameter as below:

<MyUserControl:Booking_Details runat="server" EventId='<%#
(int)(Eval("fId")) %>' />

However, the control is rendered before the set accessor is called.

Is this possible to do, or am I missing something really obvious.

Thanks

James

Oct 18 '06 #1
3 2504
do it through the ItemDataBound event of the repeater...

if the ItemType is Item or AlternatingItem, find the user control:

BookingDetails bd = (BookingDetails)e.Item.FindControl("userControlId" );
bd.EventId = (int)((DataRowView)e.DataItem)["fId"];

assuming you are binding to a dataset/datatable/dataview...

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Webmills" <ja***@instantecommerce.co.ukwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Hi all

I have a repeater control containing a web user control within its'
item template field.

Is it possible to pass through a data field into the web user control,
such that this is used when rendering the web user control.

I have exposed a parameter of the web user control and attempted to
pass in the parameter as below:

<MyUserControl:Booking_Details runat="server" EventId='<%#
(int)(Eval("fId")) %>' />

However, the control is rendered before the set accessor is called.

Is this possible to do, or am I missing something really obvious.

Thanks

James

Oct 18 '06 #2
James,
You could, instead of doing it this way, add an event handler for
the itemdatabound event of the repeater. Then, you can use the
e.Item.FindControl method to find a reference to your web user control. An
example using a label is:

Label myLabel = (Label)e.Item.FindControl("myLabel");

Of course, instead of a Label you'll use the type of your usercontrol. Once
found, test to ensure that the variable isn't null first, then you should be
able to set the event id base on the repeater control's data item. The
dataitem will be a DbDataRecord and you can access it like so:

DbDataRecord record = (DbDataRecord)e.Item.DataItem;

then use it in a similar fashion to a datareader. You may have to tweak some
of the timings in the web user control to get it right as some page events
often used to setup a repeater's data, such as the Page_Load, occur after
these events in the web user control, hence why in the web user control a
lot of people use the prerender event to do processing to ensure that the
properties can be set from the parent page.
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"Webmills" <ja***@instantecommerce.co.ukwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Hi all

I have a repeater control containing a web user control within its'
item template field.

Is it possible to pass through a data field into the web user control,
such that this is used when rendering the web user control.

I have exposed a parameter of the web user control and attempted to
pass in the parameter as below:

<MyUserControl:Booking_Details runat="server" EventId='<%#
(int)(Eval("fId")) %>' />

However, the control is rendered before the set accessor is called.

Is this possible to do, or am I missing something really obvious.

Thanks

James

Oct 18 '06 #3
Thanks all, much obliged.

Oct 18 '06 #4

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

Similar topics

5
by: Scott Lyon | last post by:
I am having a strange problem. The program is a bit complex, but I'll try to simplify what I can. I apologize if this is complicated, but I think this would still be simpler than posting a bunch of...
1
by: Dot net work | last post by:
Hello. I have an interesting data binding scenario: I have a repeater control. It repeats a typical custom web user control. I also have a collection object, and each collection element...
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...
4
by: bill | last post by:
I have a Repeater control in a web user control. The web user control has a public method named PopulateRepeater which takes an ID as an parameter and populates the repeater control based on the...
0
by: Keith | last post by:
I have a repeater control that contains a HeaderTemplate and an ItemTemplate. Each item contains a checkbox with an ID of chkReconciled, and the header contains a single checkbox with an ID of...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
2
by: Dot Net Work | last post by:
I have a user control that contains a textbox and a link button. This UC sits inside a repeater control. When I click any button, any edited textbox value does not get sent back to the server...
1
by: Dave A | last post by:
I have a problem that I have boiled down to a very simple example. I have a user control that displays a some data from a business object. On one screen I have a collection of these business...
0
by: =?Utf-8?B?Qi4gQ2hlcm5pY2s=?= | last post by:
(This is a continuation of my earlier post - 'Beginners question about binding/formatting a repeater'.) I'm trying to write a fairly minimal web app using a repeater control. I am accustomed to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...
0
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...

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.