473,657 Members | 2,993 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:HyperLin k id= "editLink" ImageUrl="~/images/edit.gif"
NavigateUrl='<% # "~/DesktopModules/awsurvey/Question_Edit.a spx?ItemID="
& DataBinder.Eval (Container.Data Item, "ItemID") & "&mid=" & ModuleId
%>' Visible= "<%# IsEditable %>" runat= "server" />
<span class="normal"> Q<%#
Container.datai tem("questionNo ") %></span></td>
<td><span class="normal" style="font-size:1.1em;"><% #
Container.datai tem("question") %> </span></td>
</tr>
<tr>
<td rowspan="2">&nb sp;</td>
<td><span class="normal" style="font-size:0.7em; color:blue;"> <%#
Container.datai tem("Instructio n") %> </span></td>
</tr>
<tr>
<td><asp:PlaceH older id="ph1" runat="server"/>
<br>
<asp:panel id="otherPanel " runat=server visible="false" >
<asp:label runat="server" id="other" /> Other (please
specify)<asp:te xtbox 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 QuestionListDat aBound(Sender As Object, e As
RepeaterItemEve ntArgs)
If (e.Item.ItemTyp e = ListItemType.It em) Or _
(e.Item.ItemTyp e = ListItemType.Al ternatingItem) Then

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

case "radio" :

dim lab as new radiobuttonlist
lab.datasource = Questions.GetAn swersbyQuestion (
DataBinder.Eval (e.Item.DataIte m, "itemID"))
lab.datatextfie ld="Answer"
lab.DataValueFi eld="itemId"

lab.databind
CType(e.Item.Fi ndControl("ph1" ),
PlaceHolder).co ntrols.add(lab)

case "checkbox" :

dim lab as new checkboxlist
lab.datasource = Questions.GetAn swersbyQuestion (
DataBinder.Eval (e.Item.DataIte m, "itemID"))
lab.datatextfie ld="Answer"
lab.DataValueFi eld="itemId"
lab.databind
CType(e.Item.Fi ndControl("ph1" ),
PlaceHolder).co ntrols.add(lab)

end select

if DataBinder.Eval (e.Item.DataIte m, "other")

CType(e.Item.Fi ndControl("othe rPanel"), panel).visible= true

end if

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

sub submit_click(se nder As Object, e As System.EventArg s)

' 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.Da taSource =Questions.GetQ uestions(Module Id)
QuestionList.Da taBind()
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 1663

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

Similar topics

3
3764
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 In codebehind file. private void Page_Load(object sender, System.EventArgs e) {
1
986
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
1044
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 column 1 column 2 column 1 column 2 column 1 column 2 with so many options, datagrid, datalist, repeater, etc., I'm looking for a recommendation on which control would be the best solution.
1
1674
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 on the core, in which I will explain), the main core is the concern. I have a daily feed from a horseracing prognosticator that gets put into an sql database on a daily basis for roughly 15 popular racetracks. A user (who will need a...
4
2504
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 chkDebtor.DataValueField = "checked" -- this is a column in the table that returns 1 or 0 chkDebtor.DataTextField = "DebtorCode" chkDebtor.DataBind() Dim i As Integer = 0 While i < chkDebtor.Items.Count
4
5269
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 highlightCount as integer = 1 %>
1
1743
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 id="tdDepartment" runat="server"><asp:datalist id="dlstDept" runat="server" HorizontalAlign="Left" CellPadding="0" Width="100%"> <HeaderTemplate> <p><b>Department Info</b></p> </HeaderTemplate> <ItemTemplate>
3
1419
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" RepeatDirection="Vertical" OnItemDataBound="dlChapter_OnItemDataBound"> <ItemTemplate> <table> <tr> <td colspan="2"><%# DataBinder.Eval(Container.DataItem, "ChapterName")%></td>
0
1310
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 made using a Repeater with a Hyperlink that gets its text and URL from an SQLDataSource. - Previous to this menu, i had another menu (a TreeView) that used an
0
8384
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8302
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8499
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7314
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5630
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
4150
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
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
2
1937
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.