Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Getting data *from* a repeater (or maybe datalist?)

Thread Tools

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

Posts: n/a
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!)

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

Here is the template column for the repeater

<table border="0">
<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>
<td rowspan="2">&nbsp;</td>
<td><span class="normal" style="font-size:0.7em; color:blue;"> <%#
Container.dataitem("Instruction") %> </span></td>
<td><asplaceHolder id="ph1" runat="server"/>
<aspanel id="otherPanel" runat=server visible="false">
<asp:label runat="server" id="other" /> Other (please
specify)<asp:textbox id="otherTb" runat="server"/>

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

sub QuestionListDataBound(Sender As Object, e As

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"))


case "checkbox" :

dim lab as new checkboxlist
lab.datasource = Questions.GetAnswersbyQuestion(
DataBinder.Eval(e.Item.DataItem, "itemID"))

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)

Thing I really want answered :-
How do I read out what boxes where checked when a user hits the

Thanks for any ideas.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Maybe it will; maybe it won't iL_weReo Computer Support 7 10-13-2009 08:42 AM
Getting row data from listbox event in repeater. Sosh ASP .Net 3 06-28-2005 12:58 PM
Of Intrest ? Maybe Yes, Maybe No Old Gringo Computer Support 0 10-11-2004 01:35 AM
Maybe, just maybe @decorator syntax is ok after all Ville Vainio Python 11 08-10-2004 06:01 PM
Some concepts (Maybe LOL maybe not...) C++ 5 08-18-2003 05:48 PM