?
Solved

nested repeater - access parent data or fields

Posted on 2006-06-08
5
Medium Priority
?
713 Views
Last Modified: 2008-01-09
ASP.Net - VB

I have a repeater nested within another repeater. It is a questionnaire repeater and it holds questions in the parent repeater and possible answers in the child. In the Footer of the child repeater I have the ability to add new possible answers. The problem is when the button is clicked to add an answer I do associate it with the parent question. i can't seem to find a way to access the parent data or a field in the parent question role that will give me the id of the question. Can anyone help me out. I will post what my repeater looks like right now. I have been able to succesfully trap the itemcommand event which it seems people have a lot of trouble doing, but just can't seem to grab the data of the parent question on the itemcommand event.

<asp:repeater id="parentRepeater" runat="server">
                                                                                    <HeaderTemplate>
                                                                                          <table border="1" cellpadding="0" cellspacing="0" rules="none" frame="border" width="100%">
                                                                                                <tr bgcolor="#99cc66">
                                                                                                      <td width="50%"><strong>Question</strong></td>
                                                                                                      <td width="25%"><strong>Type</strong></td>
                                                                                                      <td width="25%"></td>
                                                                                                </tr>
                                                                                    </HeaderTemplate>
                                                                                    <itemtemplate>
                                                                                          <tr>
                                                                                                <td><%# DataBinder.Eval(Container.DataItem, "QQ_Question") %><asp:Label Runat=server ID="lblHidQQID" Visible=False text='<%# DataBinder.Eval(Container.DataItem, "QQ_ID") %>'></asp:Label></td>
                                                                                                <td><%# DataBinder.Eval(Container.DataItem, "QQ_Type") %></td>
                                                                                                <td><asp:Button id="btnQuestionRemove" Runat="server" Text="Remove Question" Font-Size="7"></asp:Button></td>
                                                                                          </tr>
                                                                                          <asp:repeater id="childRepeater" runat="server" OnItemCommand="eventRepeater_ItemCommand" OnItemDataBound="eventRepater_ItemDataBound" EnableViewState=True datasource='<%# Container.DataItem.Row.GetChildRows("myrelation")%>'>
                                                                                                <HeaderTemplate>
                                                                                                      <tr bgcolor="#ffffe4">
                                                                                                            <td></td>
                                                                                                            <td><strong>Answer Choice</strong></td>
                                                                                                            <td></td>
                                                                                                      </tr>
                                                                                                </HeaderTemplate>
                                                                                                <itemtemplate>
                                                                                                      <tr bgcolor="#ffffe4">
                                                                                                            <td>
                                                                                                                  <asp:Label ID="lblhidQCID" Runat=server Visible=False text='<%# Container.DataItem("QC_ID") %>'>
                                                                                                                  </asp:Label>
                                                                                                                  <asp:Label ID="lblhidQQID" Runat=server Visible=False text='<%# Container.DataItem("QC_Question")%>'>
                                                                                                                  </asp:Label>
                                                                                                            </td>
                                                                                                            <td><%# Container.DataItem("QC_Answer") %></td>
                                                                                                            <td>
                                                                                                                  <asp:Button id="btnAnswerRemove" Runat="server" CommandName="delete" Text="Delete Answer" Font-Size="7"></asp:Button></td>
                                                                                                      </tr>
                                                                                                </itemtemplate>
                                                                                                <FooterTemplate>
                                                                                                      <tr>
                                                                                                            <td valign="top">
                                                                                                                  <asp:Label ID="lblhiAddAnswerQQID" Runat="server" Visible="False" text=""></asp:Label>
                                                                                                            </td>
                                                                                                            <td valign="top">
                                                                                                                  <asp:TextBox ID="txtAnswer" Runat="server"></asp:TextBox></td>
                                                                                                            <td valign="top">
                                                                                                                  <asp:Button id="btnAddAnswer" Runat="server" Text="Add Answer" CommandName="add" Font-Size="7"></asp:Button></td>
                                                                                                      </tr>
                                                                                                </FooterTemplate>
                                                                                          </asp:repeater>
                                                                                    </itemtemplate>
                                                                                    <FooterTemplate>
                                                                                          <tr bgcolor="#99cc66">
                                                                                                <td width="50%"><strong>Add Question:</strong></td>
                                                                                                <td width="25%"><strong></strong></td>
                                                                                                <td width="25%"></td>
                                                                                          </tr>
                                                                                          <tr bgcolor="#99cc66">
                                                                                                <td width="50%"><asp:TextBox ID="txtQuestion" TextMode="MultiLine" Width="90%" Runat="server"></asp:TextBox></td>
                                                                                                <td width="25%"><asp:DropDownList ID="ddlQuestionType" Width="90%" Runat="server">
                                                                                                            <asp:ListItem Value="1">Multiple Choice</asp:ListItem>
                                                                                                            <asp:ListItem Value="3">Text</asp:ListItem>
                                                                                                      </asp:DropDownList></td>
                                                                                                <td width="25%"><asp:Button id="btnAddQuestion" Runat="server" Text="Add Question" CommandName="add" Font-Size="7"></asp:Button></td>
                                                                                          </tr>
                                                      </TABLE>
                                                      </FooterTemplate> </asp:repeater>
0
Comment
Question by:sesurb
  • 2
4 Comments
 
LVL 4

Expert Comment

by:svy
ID: 16864288
((Label)childRepeater.Parent.FindControl("lblHidQQID")).Text;

0
 
LVL 2

Author Comment

by:sesurb
ID: 16864695
You can't grab it that way. At the minimum you would need to use the e.Item.Parent.FindControl("lblHidQQID").Text but this still does not gt any data.
0
 
LVL 2

Author Comment

by:sesurb
ID: 16864826
I think I have maybe fixed this problem. Instead of doing it in the itemcommand if i do it in the item_databound I can get access to the data. Thanks for the attempt.
0
 
LVL 1

Accepted Solution

by:
kodiakbear earned 0 total points
ID: 16927304
Closed, 200 points refunded.
kb
Experts Exchange Moderator
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question