的onclick不是在ListView中被解雇 [英] onclick not being fired in ListView
本文介绍了的onclick不是在ListView中被解雇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的ListView的的ItemTemplate内的按钮:
I have a button within the ItemTemplate of my ListView:
<asp:ListView ID="notificiationsList" runat="server">
<ItemTemplate>
<button type="submit" commandargument='<%# Eval("offerID") %>' onclick="Accept_Click" runat="server" >Accept</button>
</ItemTemplate>
</ListView>
然后,我有一个断点在我的code:
Then I have a breakpoint in my code:
protected void Accept_Click(object sender, EventArgs e)
{
.... // breakpoint here
}
然而,当我调试页面什么也不做,它不会出于某种原因到达断点?
However when I debug the page does nothing and it doesn't reach the breakpoint for some reason?
有谁明白我做错了吗?
推荐答案
我不完全相信你如何绑定你的ListView。我创建了以下code有一些调整,你有什么上面。
I'm not entirely sure how you are binding your ListView. I created the following code with a few tweaks to what you have above.
<asp:ListView ID="lvNotification" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lbAccept" runat="server" OnClick="Accept_Click" CommandArgument="test" Text="Accept" />
</ItemTemplate>
</asp:ListView>
绑定的ListView:
Binding the ListView:
List<string> tL = new List<string>(){ "this", "and", "that"};
lvNotification.DataSource = tL;
lvNotification.DataBind();
和我重用你的点击code:
And I reused your click code:
protected void Accept_Click(object sender, EventArgs e)
{
// breakpoint here
}
我能够命中断点没有问题。
I was able to hit the breakpoint without issue.
这篇关于的onclick不是在ListView中被解雇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文