我有一个网格视图。
<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事件。知道为什么我的代码一开始不调用事件。
此致