Page lifecycle stops after command from ListView
I have a ListView in a web form (c#/.net 4.0). There is an ImageButton in the ItemTemplate.
After a postback, the ItemCommand event fires... and then everythings stops. No other page events occur. (Actually there is one other thing: Dispose() from ExtenderControlBase runs right after the event code finishes - this site has some AjaxControltoolkit controls, though there are none on this particular page).
There are a lot of things involved here so it's not really practical to post all开发者_运维百科 the code, but generally, is there anything that could cause this?
I am rebinding the ListView on each postback, because I'm handling paging on the server side. When I assign the data source to the ListView, it's initially going to have no rows. So at the time the command event fires, the DataSource has no data in it, since it hasn't yet been loaded from the database and rebound. I can't think why this would cause the entire page to just stop loading, though.
The template is just this:
<ItemTemplate>
<tr>
<td class="DataListRow"><asp:ImageButton ID="edit" runat="server" ImageUrl="~/images/nav/datagrid_edit.gif" CommandName="edit" />
</td>
// a few orther cells
</tr>
</ItemTemplate>
Thoughts?
Doesn't sound right to me.
In these situations, I take an approach like this:
- First, make sure the page is checked into source control or otherwise backed up.
- If possible, create an new page and copy in just the controls and associated code that is blowing up. See if it works in isolation. If it doesn't work in isolation, well, you've isolated the problem.
- If you can't do that due to complexity, or if the code works fine in isolation, go to your problem page and start ripping out all the other functionality. Seriously. Systematically remove controls and features on by one, starting with whatever is the most complex.
- Eventually, after one of your changes the abberant behavior will stop, and whatever you removed last is in some way the culprit. See if you can get a fix together.
- Roll back and apply the fix.
This hasn't failed me yet.
精彩评论