I'm having trouble getting a field from my parent repeater in the click of my linkbutton that is inside another repeater (child).
My parent repeater contains the report code and other information and my child repeater contains the dates for this report. When the user clicks on a certain date I need to get this code from the parent and also pick the date to do so. But I can not do either one or the other.
Follow my html:
<asp:Repeater ID="Repeater1" OnItemDataBound="rptRelatorioFavoritos_ItemDataBound" runat="server">
<HeaderTemplate>
<table>
<tr class="titulo">
<th colspan="4">Favoritos</th>
</tr>
<tr>
<th width="5%" class="td_titulo">Relatório</th>
<th width="10%" class="td_titulo">Assunto</th>
<th width="20%" class="td_titulo">Descrição</th>
<th width="25%" class="td_titulo">Clique na Data Desejada</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="tr_branco">
<td class="td_branco">
<asp:ImageButton CommandArgument='<%#DataBinder.Eval(Container.DataItem, "CodRelatorio")%>' ID="imgbFavorito" ImageUrl="~/Content/imgs/BookDel.gif" OnCommand="imgbFavorito_Command" runat="server" ToolTip="Remover do seus favoritos?" />
<asp:Label ID="lblCodRelatorio" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "CodRelatorio")%>' />
</td>
<td class="td_branco">
<asp:Label ID="lblAssunto" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "AssuntoRelatorio")%>'></asp:Label>
</td>
<td class="td_branco">
<asp:Label ID="lblDescricao" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "DescricaoRelatorio")%>'></asp:Label>
</td>
<td class="td_branco">
<asp:Label ID="lblLocal" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "LojaRelatorio")%>'></asp:Label>
<asp:Repeater ID="rptRelFilho" OnItemDataBound="rptRelFilho_OnItemDataBound" OnItemCommand="rptRelFilho_OnItemCommand" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lkbDataRelatorio" runat="server"><%#DataBinder.Eval(Container.DataItem, "DataRelatorio")%></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
<asp:LinkButton ID="lkbDataRelatorio02" runat="server">...</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
My .cs looks like this:
protected void rptRelFilho_OnItemCommand(object source, RepeaterCommandEventArgs e)
{
var itensPai = e.Item.Parent.Parent;
var lblCodRel = (Label)itensPai.FindControl("CodRelatorio");
var link = (LinkButton)e.Item.FindControl("DataRelatorio");
string v = link.Text;
}
Follow the image of the report so you know what I'm trying to do.