简体   繁体   中英

OnSelectedIndexChanged in a listview not firing

I have a listview with a linkbutton, also tried with imagebutton, and what I want to do is to call the "DummyChanged" method in my code behind by using a OnSelectedIndexChanged inside the listview and using a linkbutton with the CommandName="Select".

The problem is that this is not working, when I click on the button, no error occurs, nor exception.

    <asp:ListView ID="lvwDummy" runat="server"
        DataSourceID="odsDummy"
        DataKeyNames="Id"
        OnSelectedIndexChanged="DummyChanged" >

        <LayoutTemplate>
            <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
        </LayoutTemplate>

        <ItemTemplate>
            <input runat="server"
                    type="checkbox"
                    id="cbxApplication"
                    onclick='CheckOne(this)'
                    value='<%# Eval("Id") %>'
             />
             <asp:LinkButton ID="lnkDummy" runat="server" 
                 CommandName="select" >
                    <asp:Image ID="imgDummy" runat="server"
                        ImageUrl="Dummy.jpg"
                        ToolTip="Dummy" />
             </asp:LinkButton>
        <br /><br />
        </ItemTemplate>
    </asp:ListView>

    <asp:ObjectDataSource ID="odsDummy" runat="server"
        TypeName="XPTO.MyDummy.MyDummyController, XPTO, Version=1.0.0.0,  Culture=neutral, PublicKeyToken=60d2c0583f4c4a69"
        DataObjectTypeName="MyDummyViewModel"
        SelectMethod='GetAllDummys'
     />

I'm trying to call this code behind:

    protected void DummyChanged(object sender, EventArgs e)
    {
        new SimpleLogger().LogInformation("Dummy: SelectedIndexChanged");
        this.DataBind();
    }

Any ideas of how to solve this?

Thanks in advance!

我的猜测是你DataBindingListViewPage_Load或地方上的每个后回导致事件不火。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM