FindControl

A

aratienza

We have a repeater inside a datagrid inside a repeater. How can we access
the datagrid from the inner repeater?

We've tried something like this in the inner repeater's itemdatabound:

DataGrid dg1 = (DataGrid)parentRepeater.FindControl("DataGridControl")

The code doesn't work.

Any help is appreciated.

Thank you,
Arlynn
 
A

aratienza

Thank you for your reply but the code didn't work.

However, the code below works. I don't know why but it works.
(DataGrid)((((((Repeater)sender).Parent).Parent).Parent).Parent);

Below is the code snippet from my ASPX page:

<asp:Repeater
ID="rptIntervals"
Runat="server"
OnItemDataBound="rptIntervals_ItemDataBound">

<itemtemplate>
<table width="100%">
<tr>
<td>
<%#DataBinder.Eval(Container.DataItem, "Interval")%>
</td>
</tr>
</table>


<asp:DataGrid
ID="MAPPsDataGrid"
Runat="server"
OnItemDataBound="MAPPsDataGrid_ItemDataBound">

<Columns>
<asp:boundcolumn
datafield="DocumentID"
headertext="DocumentID" Visible="True"/>

<asp:boundcolumn
datafield="IntervalID"
headertext="IntervalID" Visible="False"/>

<asp:TemplateColumn
HeaderText="Process">
<ItemTemplate>
<asp:HyperLink
ID="lnkViewMAPP"
Runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>

<asp:boundcolumn
datafield="EffectiveDate"
headertext="Eff. Date"/>

<asp:templatecolumn
headertext="Related Materials">
<itemtemplate>
<asp:repeater
ID="rptDocumentTypes"
Runat="server"
OnItemDataBound="rptDocumentTypes_ItemDataBound">

<itemtemplate>
<table width="200">
<tr>
<td class="bodyText">
<b><asp:label cssclass="Toggle" id="lblDocumentType"
runat="server"/></b><br>

</td>
</tr>

<tr
id="<%#rptIntervals.Items.Count%><%#DataBinder.Eval(Container.DataItem,
"DocumentTypeID")%>menu" style="display:visible">
<td class="bodyText">
<asp:repeater
ID="rptRelatedDocuments"
Runat="server"
ItemDataBound="rptRelatedDocuments_ItemDataBound">
<itemtemplate>
<ol class="RelatedDocuments">
<asp:label
cssclass="Toggle"
id="lblRelatedDocuments"
runat="server"/>
</ol>
</itemtemplate>
</asp:repeater>
</td>
</tr>
</table>

</itemtemplate>
<asp:repeater>
</itemtemplate>
</asp:templatecolumn>

</Columns>
</asp:DataGrid>
</itemtemplate>
</asp:Repeater>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top