我创建了一个 Web 应用程序,其中我使用了 onrowcommand 并在后面的代码中创建了处理程序,现在我在空模板中有一个按钮,每当我单击该按钮时,我的 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" %>
这工作了一次,之后就再也没有工作了。有谁知道是什么原因造成的。