onrowcommand を使用してハンドラーをコード ビハインドで作成した Web アプリケーションを作成しました。今では、空のテンプレート内にボタンがあり、ボタンをクリックするたびに onRowCommand が実行されません。以下は私のコードです。
<asp:GridView ID="grdExternalLinkSection1" runat="server" Width="100%" AutoGenerateColumns="false" CellPadding="5" OnRowCommand="grdExternalLinkSection_RowCommand">
<EmptyDataTemplate>
External Link Title
<asp:TextBox ID="txtExternalLinkTitleEmptySection1" runat="server"></asp:TextBox>
External Link Url
<asp:TextBox ID="txtExternalLinkUrlEmptySection1" runat="server"></asp:TextBox>
<asp:Button ID="btnExternalLinkEmptySection1" runat="server" Text="Add" CommandArgument="1" CommandName="headernew" style="padding:3px; width:56px;" />
</EmptyDataTemplate>
</asp:GridView>
他にもフィールドがありますが、これが私が話していることです。これが、RowCommand イベントのハンドラーの背後にある私のコードです。
protected void grdExternalLinkSection_RowCommand(object sender, GridViewCommandEventArgs e)
{
Response.Write("welcome");
}
ハンドラーを実行することはありません。以下は私のページディレクティブです。
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NewsletterASPVersion.ascx.cs" Inherits="RWO_Controls_NewsletterASPVersion" %>
これは一度機能し、その後は機能しませんでした。何がこれを引き起こしているのか誰にもわかりません。