473,776 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Radio Button List in Repeater Control

4 New Member
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
Mar 7 '08 #1
4 5722
nateraaaa
663 Recognized Expert Contributor
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
Mar 7 '08 #2
CURTISLESPERANCE
4 New Member
Ya, that's the key, what is the logic to it, what do I need to use to make this happen?
Mar 10 '08 #3
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.
Mar 10 '08 #4
CURTISLESPERANCE
4 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. <table width="100%" cellpadding="0" cellspacing="0" border="0">
  2.     <asp:Repeater runat="server" ID="RepWorkArea" OnItemDataBound="ShowQuestions">
  3.         <ItemTemplate>
  4.             <tr>
  5.                 <td colspan="3">
  6.                     <h4><%# ((DataRowView)Container.DataItem)["WorkArea"]%></h4>
  7.                 </td>
  8.             </tr>
  9.             <asp:Repeater ID="RepQuestions" OnItemDataBound="ShowSubQuestions" runat="server">
  10.                 <itemtemplate> 
  11.                 <tr>
  12.                     <td width="90px"><asp:RadioButtonList ID="radQuestionList" runat="server" DataSourceID="SqlDataSource1" DataValueField="SkillImportanceID" OnSelectedIndexChanged="btnViewSkill_Click" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/></td>
  13.                     <td width="*"><b><%# (Container.ItemIndex + 1) %>.</b> <%# ((DataRowView)Container.DataItem)["Question"]%></td>
  14.                     <td width="70px" align="right"><asp:RadioButtonList ID="radSubQuestionList" runat="server" DataSourceID="SqlDataSource2" DataValueField="AnswerID" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/></td>
  15.                 </tr>
  16.                 <tr>
  17.                     <td colspan="3" align="left">
  18.                         <table width="100%"  cellpadding="0" cellspacing="0" border="0">
  19.                             <asp:repeater id="RepSubQuestions" runat="server"> 
  20.                                 <itemtemplate>
  21.                                 <tr>
  22.                                     <td width="90px">
  23.                                         <asp:RadioButtonList ID="radQuestionList" runat="server" DataSourceID="SqlDataSource1" DataValueField="SkillImportanceID" OnSelectedIndexChanged="btnViewSkill_Click" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/>
  24.                                     </td>
  25.                                     <td width="*">
  26.                                         <div id="SubQuestions">
  27.                                             <li class="bold"><%# DataBinder.Eval(Container.DataItem, "[\"Question\"]")%></li>
  28.                                         </div>
  29.                                     </td>
  30.                                     <td width="70px" align="right">
  31.                                         <asp:RadioButtonList ID="radSubQuestionList" runat="server" DataSourceID="SqlDataSource2" DataValueField="AnswerID" RepeatDirection="Horizontal" DataTextField="empty" RepeatLayout="flow"/>
  32.                                     </td>
  33.                                 </tr>
  34.                                 </itemtemplate> 
  35.                             </asp:repeater>   
  36.                         </table>
  37.                     </td>
  38.                 </tr>
  39.                 </itemtemplate> 
  40.             </asp:Repeater>
  41.         </ItemTemplate>
  42.     </asp:Repeater>
  43. </table>
  44.  
//Code Behind

Expand|Select|Wrap|Line Numbers
  1. private SqlConnection connString = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString.ToString());
  2.  
  3.     protected void Page_Load(object sender, EventArgs e)
  4.     {
  5.         string strSql;
  6.         DataSet ds = new DataSet();
  7.         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";
  8.         SqlDataAdapter daWorkAreas = new SqlDataAdapter(strSql, connString);
  9.         daWorkAreas.Fill(ds, "WorkAreas");
  10.         strSql = "select * from EvaluationQuestions WHERE ParentId = -1 AND Active = 1 AND EvaluationID = 1 Order By EvaluationQuestionID";
  11.         SqlDataAdapter daEvaluationQuestions = new SqlDataAdapter(strSql, connString);
  12.         daEvaluationQuestions.Fill(ds, "EvaluationQuestions");
  13.         strSql = "select * from EvaluationQuestions WHERE Active = 1 AND EvaluationID = 1 Order By EvaluationQuestionID";
  14.         SqlDataAdapter daSubQuestions = new SqlDataAdapter(strSql, connString);
  15.         daSubQuestions.Fill(ds, "SubQuestions");
  16.         DataRelation rel = new DataRelation("QuestionsRel",ds.Tables["WorkAreas"].Columns["WorkAreaID"], ds.Tables["EvaluationQuestions"].Columns["WorkAreaID"],false);
  17.         ds.Relations.Add(rel);
  18.         DataRelation rel2 = new DataRelation("QuestionsRel2", ds.Tables["EvaluationQuestions"].Columns["EvaluationQuestionID"], ds.Tables["SubQuestions"].Columns["ParentID"], false);
  19.         ds.Relations.Add(rel2);
  20.         RepWorkArea.DataSource = ds.Tables["WorkAreas"].DefaultView;
  21.         RepWorkArea.DataBind();
  22.         connString.Close();
  23.  
  24.     }
  25.  
  26.     public void ShowQuestions(Object sender, RepeaterItemEventArgs e)
  27.     {
  28.         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
  29.         {
  30.             ((Repeater)e.Item.FindControl("RepQuestions")).DataSource =
  31.             ((DataRowView)e.Item.DataItem).CreateChildView("QuestionsRel");
  32.             ((Repeater)e.Item.FindControl("RepQuestions")).DataBind();
  33.         }
  34.     }
  35.  
  36.     public void ShowSubQuestions(Object sender, RepeaterItemEventArgs e)
  37.     {
  38.         if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
  39.         {
  40.             ((Repeater)e.Item.FindControl("RepSubQuestions")).DataSource =
  41.             ((DataRowView)e.Item.DataItem).CreateChildView("QuestionsRel2");
  42.             ((Repeater)e.Item.FindControl("RepSubQuestions")).DataBind();
  43.         }
  44.     }
  45.  
Mar 10 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
8765
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
4
2577
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
1
1777
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...
1
2131
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 ------------------------------------
2
2256
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...
3
5949
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...
1
2134
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
1
4350
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...
4
2520
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...
0
10292
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, 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...
0
10122
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 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...
1
10061
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
8954
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...
1
7471
isladogs
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...
0
6722
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
5368
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
5497
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2860
bsmnconsultancy
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...

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.