我有一个网格视图。
<asp:GridView AutoGenerateDeleteButton="false" AutoPostBack="true" OnRowCommand="gwDeleteNAV_RowCommand" OnRowCreated="gwDeleteNAV_OnRowDataBound" OnRowDeleting="DeleteButtonClick" ID="gwDeleteNAV" runat="server" AllowSorting="true" AutoGenerateColumns="False" Width="557px" OnRowDataBound="gwDeleteNAV_OnRowDataBound">
<AlternatingRowStyle BackColor="White" Font-Names="Verdana" Font-Size="Medium" HorizontalAlign="Left" />
<EmptyDataRowStyle BackColor="#EFF3FB" Font-Names="Verdana" Font-Size="Small" HorizontalAlign="Left" />
<rowstyle Height="30px" />
<alternatingrowstyle Height="30px"/>
<HeaderStyle Height="30px" BackColor="#999999" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt"
ForeColor="White" />
<Columns>
<asp:BoundField DataField="Tranid" HeaderText="Id"></asp:BoundField>
<asp:BoundField DataField="FundName" HeaderText="Fund Name"></asp:BoundField>
<asp:BoundField DataField="value" HeaderText="Price"></asp:BoundField>
<asp:BoundField DataField="date" HeaderText="Date"></asp:BoundField><asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" Text="Delete" AutoPostBack="true" OnCommand="lnkDelete_Command" runat="server" OnClientClick="return DeleteConfirmation();"
CommandArgument='<%#Eval("TranId")%>' ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField></Columns>
<SelectedRowStyle BackColor="#507CD1" />
<PagerStyle BackColor="#999999" />
</asp:GridView>
在服务器端,我正在处理链接按钮事件,如下所示:
protected void lnkDelete_Command(object sender, CommandEventArgs e)
{
string transactionid = e.CommandArgument.ToString();
DeleteNAVData(transactionid);
}
Page_Load 事件:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillDropDown();
}
}
我在这里面临的问题是,当我单击 UI 中的删除链接时,它不会触发 lnkDelete_Command,但会显示 javascript 警报。当我再次单击第二次时,它会触发 lnkDelete_command 事件。任何想法为什么我的代码一开始没有调用事件。
问候,