ASP.NET - Control Events Not Firing Inside Repeater

别说谁变了你拦得住时间么 提交于 2019-12-04 03:11:04

Your edited code has residual CommandArgument and CommandName properties; are you actually handling the Repeater.ItemCommand event?

If so, and if your page calls the control's Fill method on postbacks, that would explain it.

This classic ASP.NET hair-tearing problem is explained in these posts: A Stumper of an ASP.NET Question and A Stumper of an ASP.NET Question: SOLVED!

The explanation is a little mind-bending, but the crux of it is that Repeater.DataBind interferes with ASP.NET's ability to determine which repeater button caused a postback.

I found a missing td-tag in the Itemtemplate, sometimes when DOM is incorrect, the updatapanel do strange things.

Just about EVERY time I run into this problem it's because DataBind() is being called when it shouldn't be. This will kill most events from controls inside a repeater. I see you have an !IsPostBack check in your Page_Load... so that's a start. But try putting a breakpoint on repNotes.DataBind() and see if it's getting called when you don't expect it.

Does it work OK outside of an UpdatePanel?

I ran into the same problem. It happened with me if I've ran the DataBind twice. In other words when I populate the repeater control twice (for any reason) the events wont fire.

I hope that helps.

I ran into this problem as well. Drove me crazy because I wasn't rebinding my repeater, I tried dynamically adding an event handler, changing viewstate settings all over the place, nothing worked.

The answer in my case was that I was calling "Page.DataBind()" in the Master Page, to handle some codebehind variables that were being bound to the page using the <%#MyVar%> syntax.

Once I took out the Page.DataBind() it worked, I just had to recode the Master Page to pull in that data in a different way.

So I'm guessing if you're doing a DataBind() anywhere up the chain for your page, user control, page base class, master page, etc. it could kill your viewstate and event bubbling.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!