FindControl

Discussion in 'ASP .Net Web Controls' started by aratienza, Dec 7, 2004.

  1. aratienza

    aratienza Guest

    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
     
    aratienza, Dec 7, 2004
    #1
    1. Advertising

  2. aratienza

    aratienza Guest

    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>





    "Leon Friesema" wrote:

    > On Tue, 7 Dec 2004 13:59:07 -0800, aratienza
    > <> 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("DataGridControl")
    > >
    > >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
    >
     
    aratienza, Dec 8, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Durzi

    OnEditCommand - .FindControl Returning Null

    George Durzi, Jul 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    495
    George Durzi
    Jul 14, 2003
  2. Ravikanth[MVP]

    FindControl

    Ravikanth[MVP], Jul 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    459
    Yan-Hong Huang[MSFT]
    Jul 22, 2003
  3. James G. Beldock
    Replies:
    1
    Views:
    9,350
    Kevin Spencer
    Aug 7, 2003
  4. Ivan Demkovitch
    Replies:
    1
    Views:
    830
    Ivan Demkovitch
    Oct 7, 2003
  5. ani

    FindControl method doesn't work

    ani, Nov 5, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    375
Loading...

Share This Page