Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   FindControl (http://www.velocityreviews.com/forums/t774975-findcontrol.html)

aratienza 12-07-2004 09:59 PM

FindControl
 
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("DataGridCont rol")

The code doesn't work.

Any help is appreciated.

Thank you,
Arlynn

aratienza 12-08-2004 02:11 PM

Re: FindControl
 
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).P arent).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.Eva l(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>





"Leon Friesema" wrote:

> On Tue, 7 Dec 2004 13:59:07 -0800, aratienza
> <aratienza@discussions.microsoft.com> wrote:
>
> >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("DataGridCont rol")
> >
> >The code doesn't work.
> >
> >Any help is appreciated.
> >
> >Thank you,
> >Arlynn

>
> Each control has a Parent control which you can allocate, if none:
> null, so inside the innerRepeater: DataGrid
> dg1=((DataGrid)this.Parent);
>
> Leon
>



All times are GMT. The time now is 02:01 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.