Hi, I have the following page which all works as it should. Withing the rptQuestionAnswerType repeater I have a checkboxlist control (cbAnswer) which I need to reference (and check the nessesary values) via code. As its nested under a number of levels of repeater I am unsure how to do this, can anyone help?
I am using VS2005, ASP.NET with VB.NET 2.0
Thanks!
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Question.aspx.vb" Inherits="Question" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<h1><asp:Label ID="lblPageName" runat="server" Text=""></asp:Label></h1>
<asp:Label ID="lblPageText" runat="server" Text=""></asp:Label>
<!--Level 0 Repeater Start - The question group-->
<asp:Repeater ID="RptQuestionGroup" runat="server">
<HeaderTemplate>
<table class="QuestionPage">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="Group">
<asp:Label ID="lblGroupName" runat="server" Text='<%# Container.Dataitem("grp_name") %>'></asp:Label>
</td>
</tr>
<tr id="trGroupText" runat="server" visible='<%# iif(Container.Dataitem("grp_text") = "", False, True) %>'>
<td class="GroupText">
<asp:Label ID="lblGroupText" runat="server" Text='<%# Container.Dataitem("grp_text") %>'></asp:Label>
</td>
</tr>
<!--Level 1 Repeater Start - The Question-->
<asp:Repeater ID="RptQuestion" runat="server" datasource='<%# Ctype(Container.Dataitem,system.data.DataRowView).Row.GetChildRows("QuestionsInGroup")%>' >
<ItemTemplate>
<tr id="trQuestionName" runat="server" visible='<%# iif(Container.Dataitem("que_name") = "", False, True) %>'>
<td>
<asp:Label ID="lblQuestionName" runat="server" Text='<%# Container.Dataitem("que_name") %>'></asp:Label>
</td>
</tr>
<tr id="trQuestionText" runat="server" visible='<%# iif(Container.Dataitem("que_text") = "", False, True) %>'>
<td class="QuestionText">
<asp:Label ID="lblQuestionText" runat="server" Text='<%# Container.Dataitem("que_text") %>'></asp:Label>
</td>
</tr>
<!--Level 2 Repeater Start - The question Type, includes multipart questions such as first name/last name-->
<asp:Repeater ID="RptQuestionAnswerType" runat="server"
datasource='<%# Ctype(Container.Dataitem,system.data.DataRow).GetChildRows("QuestionTypes")%>' >
<ItemTemplate>
<!--Level 3 Data Start - Only applicible to multi answer questions (radio, checkbox, dropdown)-->
<tr id="trCheck" runat="server" visible='<%# iif(Container.Dataitem("atp_name") = "Check", true, false) %>'>
<td>
<asp:CheckBoxList ID="cbAnswer" runat="server"
DataSource='<%# Ctype(Container.Dataitem,system.data.DataRow).GetChildRows("QuestionAnswers")%>'
DataValueField="ans_id" DataTextField="ans_name" EnableViewState="true" ValidationGroup="valQuestion">
</asp:CheckBoxList>
</td>
</tr>
<!--Level 3 Data End-->
</ItemTemplate>
<FooterTemplate>
<tr>
<td class="Footer">
<!--Just a spacer row-->
</td>
</tr>
</FooterTemplate>
</asp:Repeater>
<!--Level 2 Repeater End-->
</ItemTemplate>
</asp:Repeater>
<!--Level 1 Repeater End-->
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<!--Level 0 Repeater End-->
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="valQuestion" CssClass="txtbutton" />
<br />
<asp:Label ID="lblError" runat="server"></asp:Label>
</asp:Content>
I am using VS2005, ASP.NET with VB.NET 2.0
Thanks!
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Question.aspx.vb" Inherits="Question" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<h1><asp:Label ID="lblPageName" runat="server" Text=""></asp:Label></h1>
<asp:Label ID="lblPageText" runat="server" Text=""></asp:Label>
<!--Level 0 Repeater Start - The question group-->
<asp:Repeater ID="RptQuestionGroup" runat="server">
<HeaderTemplate>
<table class="QuestionPage">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="Group">
<asp:Label ID="lblGroupName" runat="server" Text='<%# Container.Dataitem("grp_name") %>'></asp:Label>
</td>
</tr>
<tr id="trGroupText" runat="server" visible='<%# iif(Container.Dataitem("grp_text") = "", False, True) %>'>
<td class="GroupText">
<asp:Label ID="lblGroupText" runat="server" Text='<%# Container.Dataitem("grp_text") %>'></asp:Label>
</td>
</tr>
<!--Level 1 Repeater Start - The Question-->
<asp:Repeater ID="RptQuestion" runat="server" datasource='<%# Ctype(Container.Dataitem,system.data.DataRowView).Row.GetChildRows("QuestionsInGroup")%>' >
<ItemTemplate>
<tr id="trQuestionName" runat="server" visible='<%# iif(Container.Dataitem("que_name") = "", False, True) %>'>
<td>
<asp:Label ID="lblQuestionName" runat="server" Text='<%# Container.Dataitem("que_name") %>'></asp:Label>
</td>
</tr>
<tr id="trQuestionText" runat="server" visible='<%# iif(Container.Dataitem("que_text") = "", False, True) %>'>
<td class="QuestionText">
<asp:Label ID="lblQuestionText" runat="server" Text='<%# Container.Dataitem("que_text") %>'></asp:Label>
</td>
</tr>
<!--Level 2 Repeater Start - The question Type, includes multipart questions such as first name/last name-->
<asp:Repeater ID="RptQuestionAnswerType" runat="server"
datasource='<%# Ctype(Container.Dataitem,system.data.DataRow).GetChildRows("QuestionTypes")%>' >
<ItemTemplate>
<!--Level 3 Data Start - Only applicible to multi answer questions (radio, checkbox, dropdown)-->
<tr id="trCheck" runat="server" visible='<%# iif(Container.Dataitem("atp_name") = "Check", true, false) %>'>
<td>
<asp:CheckBoxList ID="cbAnswer" runat="server"
DataSource='<%# Ctype(Container.Dataitem,system.data.DataRow).GetChildRows("QuestionAnswers")%>'
DataValueField="ans_id" DataTextField="ans_name" EnableViewState="true" ValidationGroup="valQuestion">
</asp:CheckBoxList>
</td>
</tr>
<!--Level 3 Data End-->
</ItemTemplate>
<FooterTemplate>
<tr>
<td class="Footer">
<!--Just a spacer row-->
</td>
</tr>
</FooterTemplate>
</asp:Repeater>
<!--Level 2 Repeater End-->
</ItemTemplate>
</asp:Repeater>
<!--Level 1 Repeater End-->
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
<!--Level 0 Repeater End-->
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="valQuestion" CssClass="txtbutton" />
<br />
<asp:Label ID="lblError" runat="server"></asp:Label>
</asp:Content>