locked
Cannot find gridview which is inside Repeater control RRS feed

  • Question

  • User-1270756202 posted

    Hi,

    I am trying to bind data to gridview inside repeater control.But i am not able to find the control.

    Below is the code written by me

    protected void rep_ItemDataBound(object sender, RepeaterItemEventArgs e)

    {

    try

    {

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)

    {

    GridView Grid = (GridView)e.Item.FindControl("grid");

    if(Grid != null)

    {

    Grid.DataBind();

    }

    }

    }

     

    I have my grid in Item template of repeater control i just put all repeater controls in table tags

    Someone please help

    Thanks in advance

    Wednesday, September 7, 2011 6:38 PM

Answers

  • User77042963 posted

    Your GridView id is gridProduts, not grid.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 8, 2011 2:40 PM

All replies

  • User-1322853079 posted

    Did u put the Grid Control directly on the ITemTemplate or did u use any place holders like Panel Control or Tables (runat=server)

    to place the grid..?

    Wednesday, September 7, 2011 11:24 PM
  • User567269486 posted

    can you share the markup of the repeater ?

    Thursday, September 8, 2011 4:20 AM
  • User-1270756202 posted

    I placed the grid inside table of the repeater.

    my table doesn't have runat = "server" tag

    Thursday, September 8, 2011 10:39 AM
  • User-1270756202 posted

    My Repeater control

     

    <asp:Repeater runat="server" ID="repSearchResults" OnItemDataBound="repSearchResults_ItemDataBound" >
                      <HeaderTemplate>
              
                      </HeaderTemplate>
                     <SeparatorTemplate>
                      <br />
                     </SeparatorTemplate>
                     <ItemTemplate>
                                  <table border="0px">
                                    <tr>
                                       <td>
                                          <asp:LinkButton ID="linName" runat="server"><%# DataBinder.Eval(Container.DataItem, "Name")%></asp:LinkButton>
                                          <asp:LinkButton ID="linPlace" runat="server">(<%# DataBinder.Eval(Container.DataItem, "Place")%>)</asp:LinkButton>
                                       </td>                                  
                                    </tr>
                                 </table>
                                 <table border="1">
                        <tr>
                    <td colspan="1">
         <asp:LinkButton runat="server" ID="linLocation"><%# DataBinder.Eval(Container.DataItem, "Location")%></asp:LinkButton>
                                            <asp:LinkButton runat="server" ID="linService">(<%# DataBinder.Eval(Container.DataItem, "Service")%>)</asp:LinkButton>
                                            <br></br>
                             <asp:LinkButton runat="server" ID="linAddressLine1"><%# DataBinder.Eval(Container.DataItem, "Address1")%></asp:LinkButton>
                                            <br></br>
                                            <asp:LinkButton runat="server" ID="linAddressLine2"><%# DataBinder.Eval(Container.DataItem, "Address2")%></asp:LinkButton>
                                            <br></br>
                                            <asp:LinkButton runat="server" ID="linCity"><%# DataBinder.Eval(Container.DataItem, "City")%>,</asp:LinkButton>
                                            <asp:LinkButton runat="server" ID="linState"><%# DataBinder.Eval(Container.DataItem, "Stat")%></asp:LinkButton>
                                            <asp:LinkButton runat="server" ID="linZip"><%# DataBinder.Eval(Container.DataItem, "Zip")%></asp:LinkButton>
                                            <br></br>
                                            <asp:ImageButton ID="imgXfer" ImageUrl="~/images/xfer.gif" runat="server" />
                                            <br> </br>
                                            <asp:ImageButton ID="imgHistory" ImageUrl="~/images/History.gif" runat="server" />
                                            <br></br>
                          </td>
                                         <td colspan="3">
                                           <asp:GridView runat="server" ID="gridProduts">
                                                 <Columns>
                                                     <asp:TemplateField>
                                                         <ItemTemplate>
                                                            <asp:LinkButton runat="server" ID="linProduct"><%# DataBinder.Eval(Container.DataItem, "ProductName")%></asp:LinkButton><br></br>
                                                            <asp:LinkButton runat="server" ID="linName">Nickname:<%# DataBinder.Eval(Container.DataItem, "Name")%></asp:LinkButton>
                                                         </ItemTemplate>
                                                     </asp:TemplateField>
                                                     <asp:TemplateField>
                                                         <ItemTemplate>
                                                            <asp:ImageButton runat="server" ID="img" ImageUrl="~/images/img.gif"></asp:ImageButton>
                                                         </ItemTemplate>
                                                     </asp:TemplateField>
                                                     <asp:TemplateField>
                                                         <ItemTemplate>
                                                            <asp:ImageButton runat="server" ID="img2" ImageUrl="~/images/img2.gif"></asp:ImageButton>
                                                         </ItemTemplate>
                                                     </asp:TemplateField>
                                                     <asp:TemplateField>
                                                         <ItemTemplate>
                                                            <asp:ImageButton runat="server" ID="img3" ImageUrl="~/images/img.gif"></asp:ImageButton>
                                                         </ItemTemplate>
                                                     </asp:TemplateField>
                                                 </Columns>
                                            </asp:GridView>
                                         </td>
                                        </tr>
                                        <tr>
                                          <td>
                                         <asp:ImageButton runat="server" ID="img4" ImageUrl="~/images/img4.gif" />
                                         </td>
                                        </tr> 
                                   </table>
                         </ItemTemplate>
                       </asp:Repeater>

    Thursday, September 8, 2011 11:51 AM
  • User77042963 posted

    Your GridView id is gridProduts, not grid.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 8, 2011 2:40 PM