473,621 Members | 2,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with a repeater and web custom control

I am having a hard time with makeing what I am trying to do work. I
am making a questionaire web app. I have a custom control that has a
label and 5 radio buttons. My problem is that each different topic
for the questionaire is in a database and each questionaire will have
a different number of questions. I am trying to use a repeater to
creat multiple copies of the control, unfortunately when I do this the
different controls act like thay are the same. Can anyone give me a
way to do what I am trying? Thanks alot

Nov 16 '05 #1
3 2729
You can use the ItemDataBound event to set a property value in the
RepeaterItem that you can retrieve when processing on PostBack.

While you don't say much about how you're using the repeater or accessing
the User Controls, a common method is to assign a value to the
CommandArgument property of a Button in your RepeaterItem from within the
ItemDataBound event handler. Then, in your event handler for ItemCommand,
you can test the value of the CommandArgument or for whatever other property
you set in your ItemDataBound handler. If your Button exists in the User
Control then just expose the Button's CommandArgument property through the
User Control.

Also, if you use the ItemCommand event to trigger your processing, you can
access the specific User Control instance by using something like this:

MyUserControl myControl =
(MyUserControl) e.Item.Controls[indexOfUserCont rol];

That would give you access to the individual User Control.

Don't make the mistake of using Item.Index to establish which item was
clicked or which item you're responding to in your PostBack processing. If
the database has changed then the contents of your Repeater.DataSo urce may
not be the same in PostBack as they were initially.

HTH

DalePres
MCAD, MCDBA, MCSE
<an**@anon.co m> wrote in message
news:ce******** *************** *********@4ax.c om...
I am having a hard time with makeing what I am trying to do work. I
am making a questionaire web app. I have a custom control that has a
label and 5 radio buttons. My problem is that each different topic
for the questionaire is in a database and each questionaire will have
a different number of questions. I am trying to use a repeater to
creat multiple copies of the control, unfortunately when I do this the
different controls act like thay are the same. Can anyone give me a
way to do what I am trying? Thanks alot

Nov 16 '05 #2
Thanks, that helped. To answer how it is being used, I have a control
that is 5 radiobuttons. This control is going to be placed for each
question in a questionaire. I want to use the repeater to put the
control on the page as many times as is needed. each Questionaire has
a different number of questions and a dropdown list is how the user
selects which questionaire to use
On Sat, 12 Mar 2005 11:20:03 -0600, "DalePres"
<don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote:
You can use the ItemDataBound event to set a property value in the
RepeaterItem that you can retrieve when processing on PostBack.

While you don't say much about how you're using the repeater or accessing
the User Controls, a common method is to assign a value to the
CommandArgumen t property of a Button in your RepeaterItem from within the
ItemDataBoun d event handler. Then, in your event handler for ItemCommand,
you can test the value of the CommandArgument or for whatever other property
you set in your ItemDataBound handler. If your Button exists in the User
Control then just expose the Button's CommandArgument property through the
User Control.

Also, if you use the ItemCommand event to trigger your processing, you can
access the specific User Control instance by using something like this:

MyUserContro l myControl =
(MyUserControl )e.Item.Control s[indexOfUserCont rol];

That would give you access to the individual User Control.

Don't make the mistake of using Item.Index to establish which item was
clicked or which item you're responding to in your PostBack processing. If
the database has changed then the contents of your Repeater.DataSo urce may
not be the same in PostBack as they were initially.

HTH

DalePres
MCAD, MCDBA, MCSE
<an**@anon.com > wrote in message
news:ce******* *************** **********@4ax. com...
I am having a hard time with makeing what I am trying to do work. I
am making a questionaire web app. I have a custom control that has a
label and 5 radio buttons. My problem is that each different topic
for the questionaire is in a database and each questionaire will have
a different number of questions. I am trying to use a repeater to
creat multiple copies of the control, unfortunately when I do this the
different controls act like thay are the same. Can anyone give me a
way to do what I am trying? Thanks alot

Nov 16 '05 #3
Well, sounds like you may have it solved by now, but just in case:

Since your data isn't going to change between round trips, and you don't
have a button on any given RepeaterItem, when the user submits the form, all
you have to do is loop through the Repeater.Items collection like this:

foreach (RepeaterItem item in MyRepeater.Item s)
{
MyUserControl myUserControl =
(MyUserControl) item.Controls[userControlInde x];
// do some stuff with myUserControl
}

DalePres

<an**@anon.co m> wrote in message
news:p9******** *************** *********@4ax.c om...
Thanks, that helped. To answer how it is being used, I have a control
that is 5 radiobuttons. This control is going to be placed for each
question in a questionaire. I want to use the repeater to put the
control on the page as many times as is needed. each Questionaire has
a different number of questions and a dropdown list is how the user
selects which questionaire to use
On Sat, 12 Mar 2005 11:20:03 -0600, "DalePres"
<don-t-spa-m-me@lea-ve-me-a-lone--.com> wrote:
You can use the ItemDataBound event to set a property value in the
RepeaterIte m that you can retrieve when processing on PostBack.

While you don't say much about how you're using the repeater or accessing
the User Controls, a common method is to assign a value to the
CommandArgume nt property of a Button in your RepeaterItem from within the
ItemDataBou nd event handler. Then, in your event handler for ItemCommand,
you can test the value of the CommandArgument or for whatever other
property
you set in your ItemDataBound handler. If your Button exists in the User
Control then just expose the Button's CommandArgument property through the
User Control.

Also, if you use the ItemCommand event to trigger your processing, you can
access the specific User Control instance by using something like this:

MyUserContr ol myControl =
(MyUserContro l)e.Item.Contro ls[indexOfUserCont rol];

That would give you access to the individual User Control.

Don't make the mistake of using Item.Index to establish which item was
clicked or which item you're responding to in your PostBack processing.
If
the database has changed then the contents of your Repeater.DataSo urce may
not be the same in PostBack as they were initially.

HTH

DalePres
MCAD, MCDBA, MCSE
<an**@anon.co m> wrote in message
news:ce****** *************** ***********@4ax .com...
I am having a hard time with makeing what I am trying to do work. I
am making a questionaire web app. I have a custom control that has a
label and 5 radio buttons. My problem is that each different topic
for the questionaire is in a database and each questionaire will have
a different number of questions. I am trying to use a repeater to
creat multiple copies of the control, unfortunately when I do this the
different controls act like thay are the same. Can anyone give me a
way to do what I am trying? Thanks alot


Nov 16 '05 #4

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

Similar topics

45
3012
by: Joh | last post by:
hello, i'm trying to understand how i could build following consecutive sets from a root one using generator : l = would like to produce : , , , ,
6
1372
by: WebMatrix | last post by:
Hello, Here's the situation (I'll try to be brief as possible) I am working on the control which is created dynamically based on XML string. This control consists of a table with number of rows with 3 columns; TextBox, dropdown and a button ("Delete" button) in each column. Also there's one button at the bottom of the table that allows users to add more rows. So more controls will be added programmatically as user adds more rows. What's...
1
2000
by: Jack | last post by:
I have a repeater bound to a collection of business objects: ScoresRepeater.DataSource = objReferralTestScore.TestScore; ScoresRepeater.DataBind(); How can I add a "new" row to the repeater without adding to the collection of bus objects? Thanks in advance, Jack.
0
883
by: anon | last post by:
I am having a hard time with makeing what I am trying to do work. I am making a questionaire web app. I have a custom control that has a label and 5 radio buttons. My problem is that each different topic for the questionaire is in a database and each questionaire will have a different number of questions. I am trying to use a repeater to creat multiple copies of the control, unfortunately when I do this the different controls act like...
0
1172
by: Gordon Smith | last post by:
Hi, Am writing a server control which contains a repeater control. I followed the code outlined by Rachel@discussions.microsoft.com (many thanks) on the following thread: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=A69AC6CD-0A87-4A8B-A2AA-9719B731F2BE%40microsoft.com&rnum=1&prev=/groups%3Fq%3DInstantiateIn%2Brepeater%2Bevent%26ie%3DUTF-8%26hl%3Den%26btnG%3DGoogle%2BSearch I wish to extend the InstantiateIn code to...
9
4684
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate> /asp:Repeater> The DataSource for this Repeater is a CollectionBase of objects and is
1
2447
by: criz | last post by:
Hi All, I have a repeater that required a check box on each item in the repeater to be validated against eachother (to check if only one item's checkbox is ticked.) To perform this validation I created a validation control that inherits from BaseValidator and performs server and client side checks and is performing the validation on the repeater control. The above all works except I cant get the client validation to stop the page from...
1
2390
by: jl817cn | last post by:
It's strange. The page is using master page, the repeater control is placed in contentplaceholder. In repeater Itemtemplate, there are several labels and textboxes, the value of textboxes is from database. there is another custom control in repeater, which inherit the label control, just add one customer property MyID. In page_load I will also call another function to set the text of custom label. the function loop through all the...
1
1840
by: Doogie | last post by:
Hi, I have been trying to get a checkbox added to a repeater control of mine and then try to access events of the repeater control when a user clicks the checkbox. At first, since the control is tied to xsl, I added the checkbox there. That works fine, but I cannot get any information about the checkbox (i.e. checked, unchecked, etc) when I pass data from the xsl over to a method in java. I can get info on the other columns but not...
0
8653
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8597
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8457
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6101
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5554
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4065
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2587
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 we have to send another system
1
1763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.