Modal Popup Extender Show() Method does not work

I have a ListView with LinkButtons. I'm using the OnItemCommand method with a CommanName in order to open a Dialog.

If the user click on the LinkButton, I want that to open a Dialog (with controls, etc). But I every time I get the same Error:

System.InvalidOperationException: The ListView "myListView" has one SelectedIndexChanging-Event execute, which was not treated.

My Code: aspx

...

<asp:HiddenField ID="hidForModel" runat="server" />

    <asp:scriptmanager id="ScriptManager1" runat="server">
       </asp:scriptmanager> 

       <asp:modalpopupextender id="PopUpDialog" 
                runat="server" cancelcontrolid="btnCancel" 
                okcontrolid="btnOkay" targetcontrolid="hidForModel" 
                popupcontrolid="Panel1" popupdraghandlecontrolid="PopupHeader" 
                drag="true" backgroundcssclass="ModalPopupBG" >

</asp:modalpopupextender>

            <div class="popupConfirmation" id="Panel1" runat="server" >
              <asp:Panel runat="server" ID="PopupHeader" CssClass="modalPopup">Benutzerinformationen</asp:Panel>
                <div class="Body">
                    Hallo
                    <asp:TextBox ID="txtVorname" runat="server"></asp:TextBox>
                    <asp:Button id="btnOkay" runat="server" text="Speichern" />
                    <asp:Button id="btnCancel" runat="server" text="Abbrechen" />
                </div>

            </div>

...

 <asp:ListView runat="server" ID="myListView" OnItemCommand="myListView_ItemCommand">

        <LayoutTemplate>
            <table id="UserTable" runat="server" border="0" width="800" cellpadding="0" cellspacing="0">
                <tr style="background-color:#E5E5FE" class="TableClass">
                    <th id="th1" runat="server"><asp:LinkButton ID="lnkBenutzer" runat="server" >id_Benutzer</asp:LinkButton></th>
                    <th id="th2" runat="server"><asp:LinkButton ID="lnkemail" runat="server" >id_Email</asp:LinkButton></th>
                    <th id="th3" runat="server"><asp:LinkButton ID="lnkVorname" runat="server" >id_Vorname</asp:LinkButton></th>
                    <th id="th4" runat="server"><asp:LinkButton ID="lnkNachname" runat="server" >id_Nachname</asp:LinkButton></th>
                    <th id="th5" runat="server"><asp:LinkButton ID="lnkTelefon" runat="server" >id_Telefon</asp:LinkButton></th>
                </tr>
                <tr runat="server" id="ItemPlaceholder">
                </tr>
            </table>
        </LayoutTemplate>

        <ItemTemplate>

            <tr class="TableClass">    
                <td align="left" ><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink"  CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink"  CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server"  /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink"  CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server"  /></td>

              <td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>

            </tr>

        </ItemTemplate>

        <AlternatingItemTemplate>

            <tr class="TableClass"> 

                <td align="left" ><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink"  CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink"  CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" /></td>
                <td align="left"><asp:LinkButton CssClass="MyLink" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" /></td>

                <td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>

            </tr>

        </AlternatingItemTemplate>

        </asp:ListView>

...

c# code:

protected void myListView_ItemCommand(object sender, ListViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                txtVorname.Text = "test";

                PopUpDialog.Show();  //<-- Here is the error 

            }
        }

It is a mystery that I can open the Dialog using a Button (for testing), but not with the LinkButton.


protected void myListView_ItemCommand(object sender, ListViewCommandEventArgs e)
{
 if (e.CommandName == "Select")
  {
  ModalPopupExtender popUp = (ModalPopupExtender)lvAlbum.FindControl("PopUpDialog");
  popUp.Show();
  }
}

You just need to handle the SelectedIndexChanging event in the ListView.

Markup

<asp:ListView runat="server" ID="myListView" OnItemCommand="myListView_ItemCommand"
    OnSelectedIndexChanging="myListView_SelectedIndexChanging" >

Code-behind:

protected void myListView_SelectedIndexChanging(object sender, EventArgs e)
{

}

There are certain events in the ListView that need to be handled if they fire. If those events attempt to fire (like clicking a list item that has a "CommandName" of "Select" firing the SelectedIndexChanging event) and they are not handled, you get an error like the one you mentioned.