473,324 Members | 2,124 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,324 software developers and data experts.

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 2710
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[indexOfUserControl];

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.DataSource 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 #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
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[indexOfUserControl];

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.DataSource 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.Items)
{
MyUserControl myUserControl =
(MyUserControl)item.Controls[userControlIndex];
// do some stuff with myUserControl
}

DalePres

<an**@anon.com> wrote in message
news:p9********************************@4ax.com...
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
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[indexOfUserControl];

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.DataSource 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 #4

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

Similar topics

45
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
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...
1
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...
0
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...
0
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: ...
9
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>...
1
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...
1
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...
1
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.