Hi, I am trying to figure out if this is possible. I need to display 4 radio buttons next to a question then 3 radio buttons after. The 2 different group radio buttons and questions are coming from a database.
I have the questions being displayed right now using a repeater control but I am having an issue making 4 and 3 radio buttins per question for multiple questions. However some questions have sub questions so the parent question doesn't have the radio buttons. Is this possible?
E.G.
- radio|radio|rad io|radio|questi on|radio|radio| radio
- question
- radio|radio|rad io|radio|Sub question|radio| radio|radio
4 5722
Hi, I am trying to figure out if this is possible. I need to display 4 radio buttons next to a question then 3 radio buttons after. The 2 different group radio buttons and questions are coming from a database.
I have the questions being displayed right now using a repeater control but I am having an issue making 4 and 3 radio buttins per question for multiple questions. However some questions have sub questions so the parent question doesn't have the radio buttons. Is this possible?
E.G.
- radio|radio|rad io|radio|questi on|radio|radio| radio
- question
- radio|radio|rad io|radio|Sub question|radio| radio|radio
This is possible. You need to figure out the logic to make this work. I believe whatever code you write will need to be in the repeaters ItemDataBound event. This way you can identify what to display (question or question - sub question).
Nathan
Ya, that's the key, what is the logic to it, what do I need to use to make this happen?
Frinavale 9,735
Recognized Expert Moderator Expert
Ya, that's the key, what is the logic to it, what do I need to use to make this happen?
You need to implement this logic when you are retrieving the questions from your database.
I'm not sure you guys understand, so here is my code. and I need to display radio buttons for all parent questions unless it has a child question
Page code: -
<table width="100%" cellpadding="0" cellspacing="0" border="0">
-
<asp:Repeater runat="server" ID="RepWorkArea" OnItemDataBound="ShowQuestions">
-
<ItemTemplate>
-
<tr>
-
<td colspan="3">
-
<h4><%# ((DataRowView)Container.DataItem)["WorkArea"]%></h4>
-
</td>
-
</tr>
-
<asp:Repeater ID="RepQuestions" OnItemDataBound="ShowSubQuestions" runat="server">
-
<itemtemplate>
-
<tr>
-
<td width="90px"><asp:RadioButtonList ID="radQuestionList" runat="server" DataSourceID="SqlDataSource1" DataValueField="SkillImportanceID" OnSelectedIndexChanged="btnViewSkill_Click" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/></td>
-
<td width="*"><b><%# (Container.ItemIndex + 1) %>.</b> <%# ((DataRowView)Container.DataItem)["Question"]%></td>
-
<td width="70px" align="right"><asp:RadioButtonList ID="radSubQuestionList" runat="server" DataSourceID="SqlDataSource2" DataValueField="AnswerID" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/></td>
-
</tr>
-
<tr>
-
<td colspan="3" align="left">
-
<table width="100%" cellpadding="0" cellspacing="0" border="0">
-
<asp:repeater id="RepSubQuestions" runat="server">
-
<itemtemplate>
-
<tr>
-
<td width="90px">
-
<asp:RadioButtonList ID="radQuestionList" runat="server" DataSourceID="SqlDataSource1" DataValueField="SkillImportanceID" OnSelectedIndexChanged="btnViewSkill_Click" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/>
-
</td>
-
<td width="*">
-
<div id="SubQuestions">
-
<li class="bold"><%# DataBinder.Eval(Container.DataItem, "[\"Question\"]")%></li>
-
</div>
-
</td>
-
<td width="70px" align="right">
-
<asp:RadioButtonList ID="radSubQuestionList" runat="server" DataSourceID="SqlDataSource2" DataValueField="AnswerID" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/>
-
</td>
-
</tr>
-
</itemtemplate>
-
</asp:repeater>
-
</table>
-
</td>
-
</tr>
-
</itemtemplate>
-
</asp:Repeater>
-
</ItemTemplate>
-
</asp:Repeater>
-
</table>
-
//Code Behind -
private SqlConnection connString = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString());
-
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
string strSql;
-
DataSet ds = new DataSet();
-
strSql = "select distinct A.* from WorkAreas as A right Join EvaluationQuestions AS B on a.WorkAreaId = B.WorkAreaID AND B.EvaluationID = 1 Order By A.SortOrder";
-
SqlDataAdapter daWorkAreas = new SqlDataAdapter(strSql, connString);
-
daWorkAreas.Fill(ds, "WorkAreas");
-
strSql = "select * from EvaluationQuestions WHERE ParentId = -1 AND Active = 1 AND EvaluationID = 1 Order By EvaluationQuestionID";
-
SqlDataAdapter daEvaluationQuestions = new SqlDataAdapter(strSql, connString);
-
daEvaluationQuestions.Fill(ds, "EvaluationQuestions");
-
strSql = "select * from EvaluationQuestions WHERE Active = 1 AND EvaluationID = 1 Order By EvaluationQuestionID";
-
SqlDataAdapter daSubQuestions = new SqlDataAdapter(strSql, connString);
-
daSubQuestions.Fill(ds, "SubQuestions");
-
DataRelation rel = new DataRelation("QuestionsRel",ds.Tables["WorkAreas"].Columns["WorkAreaID"], ds.Tables["EvaluationQuestions"].Columns["WorkAreaID"],false);
-
ds.Relations.Add(rel);
-
DataRelation rel2 = new DataRelation("QuestionsRel2", ds.Tables["EvaluationQuestions"].Columns["EvaluationQuestionID"], ds.Tables["SubQuestions"].Columns["ParentID"], false);
-
ds.Relations.Add(rel2);
-
RepWorkArea.DataSource = ds.Tables["WorkAreas"].DefaultView;
-
RepWorkArea.DataBind();
-
connString.Close();
-
-
}
-
-
public void ShowQuestions(Object sender, RepeaterItemEventArgs e)
-
{
-
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
-
{
-
((Repeater)e.Item.FindControl("RepQuestions")).DataSource =
-
((DataRowView)e.Item.DataItem).CreateChildView("QuestionsRel");
-
((Repeater)e.Item.FindControl("RepQuestions")).DataBind();
-
}
-
}
-
-
public void ShowSubQuestions(Object sender, RepeaterItemEventArgs e)
-
{
-
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
-
{
-
((Repeater)e.Item.FindControl("RepSubQuestions")).DataSource =
-
((DataRowView)e.Item.DataItem).CreateChildView("QuestionsRel2");
-
((Repeater)e.Item.FindControl("RepSubQuestions")).DataBind();
-
}
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michael Albanese |
last post by:
I am developing an application to handle my compay's OSHA
reporting requirements.
Some of the input criteria are technical and narowly
defined, so I was trying to prvide what i call "Context
Sensitive Help" by providing a short instructional message
based on which control has Focus.
Because of the way that a Radio Button List control is
rendered in the browser i can not attach an onFocus event
|
by: cwwilly |
last post by:
Hello,
Thanks for taking a look at this!
Problem:
I'm trying to pass multiple dynamic values between a slaveform and a
masterform. The problem I'm having is on the slaveform I loop through
multiple records and want two values depending on the row they select.
slaveform: x=selected
|
by: .Net Newbie |
last post by:
I am relatively new to .Net and have been coding an intranet site for my
employer for a couple of months. I am currently stuck coding in a
text-editor called EditPlus without access to the VS.Net IDE, and coding
pages with the script directly in each page (not using the codebehind
method) as most of my learning material has demonstrated. I started with
the IBuySpy Portal (SDK version not VS Version) as my base portal and have
coded...
|
by: Mike |
last post by:
Hi!
Been stuck on this one for a bit. Would really appreciate any help on
this one.
To start. I have a sql database table with the following data and
design (ex)
------------------------------------
provider_id | plan_id | plan cost
------------------------------------
|
by: Antoine |
last post by:
I would like to construct my own list of items in a grid/ table/ item list
layout but I have a problem. I want to add a sort of index row based on
time, such as there might be blank values.
Sure the data list I have at the moment is in order, but I would like to
have each interval possible, and instead of repeating the row index (the
time value) I would like to list it once and then list the items within it
(the items associated with...
| |
by: David Hearn |
last post by:
I have a datalist that I have inserted a radio button into. The datalist
populates with a list of items and each one has a radio button next to it. I
need to use the radio button to allow the user to select a default item so
when the user clicks one of the radio buttons, it needs to clear the checked
property from the rest. This is default behavior for the radio button, but
it doesn't work when it is embedded into a datalist. I have tried...
|
by: SouthSpawn |
last post by:
I know this is probably pretty trival.
I am trying to put a radio button inside
a repeater control. That will allow me to select each row one by one. Then
once the user clicks on the submit button. It determines which row has been
selected.
Can anyone post me a code sample.
Thanks,
Mark
|
by: Dave A |
last post by:
I have a problem that I have boiled down to a very simple example.
I have a user control that displays a some data from a business object. On one screen I have a collection of these business objects and wish to display the user control multiple times. On this web page I simply bind the repeater to the data source and in the ItemDataBound event dynamically load the user control via "LoadControl()".
The user control contains an auto post...
|
by: Blasting Cap |
last post by:
I have a page that has a number of radio buttons that will be displayed
to different access levels of a user who logs in to my website.
For instance, if there are a dozen buttons, user1 will see all twelve.
User2 would see buttons 1-3,10-12 and NOT any others, and so on.
Since there are several buttons on the page (each one would run a report
for them), is there a way to - in an onclick event for each of the
buttons - to...
|
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...
|
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...
| |
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,...
|
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...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |