1

リスト ビューでイメージ ボタンとリンク ボタンを使用し、onload メソッドでデータをバインドしています。イメージ ボタンの oncommand は正常に動作していますが、リンク ボタンの oncommand が起動しません。

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <asp:ListView runat="server" ID="List1" >
            <ItemTemplate>
                <table>
                    <tr>
                        <td>
                            <asp:ImageButton runat="server" ID="imagebutton" ImageUrl='<%# Eval("image") %>' CommandArgument='<%# Eval("id") %>' CommandName="button"  Width="100px" Height="100px" OnCommand="imagebutton_Command" ></asp:ImageButton>
                        </td>
                        <td>
                            <asp:LinkButton ID="title" runat="server" Text='<%# Eval("title") %>' CommandArgument='<%# Eval("id") %>' CommandName="link" OnCommand="imagebutton_Command"></asp:LinkButton></td>

                    </tr>
                </table>
            </ItemTemplate>
        </asp:ListView>
</asp:Content>

oncommad イベントのコードは次のとおりです。

 protected void imagebutton_Command(object sender, CommandEventArgs e)
 {
    try
    {


        Response.Redirect("Welcome.aspx?url=" + e.CommandArgument.ToString());
    }
    catch (Exception ex)
    {
        ex.ToString();
    }
}

oncommand メソッドでブレークポイントも試しましたが、画像ボタンをクリックすると正常に動作しますが、リンクボタンをクリックすると起動せず、oncommad ブロックに入りません

4

0 に答える 0