473,387 Members | 1,791 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,387 software developers and data experts.

Multiple Radio Button List in Repeater Control

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|radio|radio|question|radio|radio|radio

- question

- radio|radio|radio|radio|Sub question|radio|radio|radio
Mar 7 '08 #1
4 5659
nateraaaa
663 Expert 512MB
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|radio|radio|question|radio|radio|radio

- question

- radio|radio|radio|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
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 Expert Mod 8TB
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
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
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...
4
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...
1
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...
1
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) ...
2
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...
3
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...
1
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...
1
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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.