How to use a ListView inside a ListView

Hi,

  I have a ListView inside a ListView and I need to processe the inner ListView data. This is the code:

    <asp:ListView ID="ListView1" runat="server" OnItemDataBound="ItemDataBound">
        <ItemTemplate>
                <asp:ListView ID="lvItems" runat="server" OnItemEditing="ItemEditing">
                    <LayoutTemplate>
                        <div id="itemPlaceholder" runat="server" style="float: left; width: 100%">
                        </div>
                    </LayoutTemplate>
                    <ItemTemplate>
                                <asp:ImageButton ID="btnEdit" runat="server" CommandName="Edit" ImageUrl="~/Imagens/btnEditar.png"
                                    ToolTip='<%# Eval("key") %>' />&nbsp;

  When I click the button (btnEdit) I need to get the corresponding info. I gues it should happen at ItemEditing but in the code lvItems is not visible because it is part of ListView1. How do I get this data? I need to read KEY value.

  Thanks,
  Marco Castro
MarcoCastroAsked:
Who is Participating?
 
MarcoCastroAuthor Commented:
I got the solution. In ItemEditing of lvItems

ImageButton ib = (sender as ListView).Items[e.NewEditIndex].FindControl("btnEdit") as ImageButton;

brings the desired info.
0
 
MarcoCastroAuthor Commented:
Hi,

  Your example shows to to populate the ListView. This I have already done.

  What I need is to process when I click the btnEdit button. I need to read the KEY data from this button that is part of a ListView that is part of another ListView.

  Thanks,
  Marco Castro
0
 
MarcoCastroAuthor Commented:
In Microsoft documentation I find the solution.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.