3
I’m having a hard time getting a field of my parent Peater at the click of my linkbutton inside another Peater (son).
My Parent contains the report code and other information and my Parent contains the dates of that report. When the user clicks on a certain date I need to take this code from the parent and tbem take the date to do the process. But I can’t do either.
Follows 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 is 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 have a sense of what I’m trying to do.