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

Getting data *from* a repeater (or maybe datalist?)

I am using PlaceHolders in a Repeater to generate a multi choice
survey. I need a way of testing to see what the placeholder has been
turned into at runtime, and reading out the data.

The admin can add questions to a survey, then add possible answers to
each question. Certain functions are also set, for example multi
answer (display with a checkboxlist) single answer (radiolist). Also
toggle the presence of an "other" selection which produces a textbox
to type into.

The questions and answers are held in a SQL Server Database.

The survey output page reads the questions from the database, and
builds the survey using a repeater.

when a "respondent" arrives to fill out the survey they click the
answers they wish, fill in the boxes and press submit.

My problem is how do i then read out the checked answers?

This link may work, may not :)

I will leave it so everyone is admin over the weekend. if you break it
i would be interested to know what you did :)
Brief instructions, click add question to add a new Q. You MUST put an
Integer in the Question number field. it does not auto number and a
null will break it.

Once a new Q is added click edit (pencil icon) and add Answers. (you
can arrange the order of A with the up and down arrow. Note how the
selected A *remains* selected!)

http://bagheera.ncl.ac.uk/dps/Deskto...ex=17&tabid=97

I am not sure what code will help make my query understandable!

Here is the template column for the repeater

<itemTemplate>
<table border="0">
<tr>
<td> <asp:HyperLink id= "editLink" ImageUrl="~/images/edit.gif"
NavigateUrl='<%# "~/DesktopModules/awsurvey/Question_Edit.aspx?ItemID="
& DataBinder.Eval(Container.DataItem, "ItemID") & "&mid=" & ModuleId
%>' Visible= "<%# IsEditable %>" runat= "server" />
<span class="normal">Q<%#
Container.dataitem("questionNo") %></span></td>
<td><span class="normal" style="font-size:1.1em;"><%#
Container.dataitem("question") %> </span></td>
</tr>
<tr>
<td rowspan="2">&nbsp;</td>
<td><span class="normal" style="font-size:0.7em; color:blue;"> <%#
Container.dataitem("Instruction") %> </span></td>
</tr>
<tr>
<td><asp:PlaceHolder id="ph1" runat="server"/>
<br>
<asp:panel id="otherPanel" runat=server visible="false">
<asp:label runat="server" id="other" /> Other (please
specify)<asp:textbox id="otherTb" runat="server"/>
</asp:panel>
</td>
</tr>
</table>
</itemTemplate>

Here is the OnDataBound sub "type" is either "radio" or "checkbox".
"other" is boolean.

sub QuestionListDataBound(Sender As Object, e As
RepeaterItemEventArgs)
If (e.Item.ItemType = ListItemType.Item) Or _
(e.Item.ItemType = ListItemType.AlternatingItem) Then

select Case DataBinder.Eval(e.Item.DataItem, "type")

case "radio" :

dim lab as new radiobuttonlist
lab.datasource = Questions.GetAnswersbyQuestion(
DataBinder.Eval(e.Item.DataItem, "itemID"))
lab.datatextfield="Answer"
lab.DataValueField="itemId"

lab.databind
CType(e.Item.FindControl("ph1"),
PlaceHolder).controls.add(lab)

case "checkbox" :

dim lab as new checkboxlist
lab.datasource = Questions.GetAnswersbyQuestion(
DataBinder.Eval(e.Item.DataItem, "itemID"))
lab.datatextfield="Answer"
lab.DataValueField="itemId"
lab.databind
CType(e.Item.FindControl("ph1"),
PlaceHolder).controls.add(lab)

end select

if DataBinder.Eval(e.Item.DataItem, "other")

CType(e.Item.FindControl("otherPanel"), panel).visible=true

end if

end if
end sub
Here is my submitClick (you can fill it in for me :)

sub submit_click(sender As Object, e As System.EventArgs)

' get list of stuff in repeater
' go through each in list
' read out checked item(or items)
' read out "other" string
' enter all into DB

end sub

I bind to the repeater at page load

QuestionList.DataSource =Questions.GetQuestions(ModuleId)
QuestionList.DataBind()
Thing I really want answered :-
How do I read out what boxes where checked when a user hits the
button.

Thanks for any ideas.

Fragg
Nov 17 '05 #1
0 1651

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

Similar topics

3
by: seeni | last post by:
I have tried retrieving the image data from NorthWind database and print in the asp page using Repeater control. But instead of showing picture, the browser is showing "System.Byte" My code is...
1
by: jernej goricki | last post by:
Which is the best way for displaying parent child records (not arbitrary, just 1 sublevel) using a Datalist or better a Repeater control? Thanks
1
by: David Bartosik - MS MVP | last post by:
I am wanting to display my data in columns horizontally across the page rather than vertically down the page to avoid scrolling. in other words rather than have column 1 column 2 I want...
1
by: .Net Sports | last post by:
I am resurrecting an old script from a previous programmer, and want to migrate it over to asp.net from classic asp. Tho there are other peripheral parts of the script (that really have no bearing...
4
by: Patrick.O.Ige | last post by:
I'm DataBinding a CheckBoxList and i want to get the checkboxes selected when the page is loaded depending on a Boolean value from the Database.. chkDebtor.DataSource = objDR...
4
by: darrel | last post by:
I have a repeater that I'd like to apply some logic to, namly highlighting the top few items in the repeater. To do this, I need to determine the record count. I've tried this: <% dim...
1
by: Simon Cheng | last post by:
When I tried to display data in datalist and repeater, the first data item always disappears in all datalist and repeaters in my web forms. The code I use for the html page is: <TD...
3
by: GD | last post by:
I'm using a DataList and a Repeater (nested in the DataList) to display a list of "Chapters" and "Documents" within the Chapters. <asp:DataList ID="dlChapter" Runat="server" RepeatColumns="2"...
0
by: warren_rapson | last post by:
Hi all, I am a newbie to this awesome framework - i love it. My situation: - I have a master page with a menu on it and a ContenPlaceHolder containing a DataList - The menu is dynamic and is...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.