Last post Nov 22, 2005 07:22 PM by imagemaker
Nov 21, 2005 01:32 PM|Baatezu|LINK
Nov 22, 2005 02:46 PM|imagemaker|LINK
Nov 22, 2005 02:56 PM|Baatezu|LINK
1. Make sure that you are not rebinding the datasource to the repeater on each postback - be sure to include the databind call within the If Not Page.IsPostBack Then block.
2. Make sure that the repeater's EnableViewState has not been intentionally set to false. It should be true (which is the default and which is required for the ItemCommand event to be properly fired).
Nov 22, 2005 07:22 PM|imagemaker|LINK
I apparently did not read your first post closely enough to see that you are trying to raise the Repeater's ItemCommand by clicking on a DropDownList, Checkbox, or RadioButton. When I saw mention of the Checkbox control in your last post, I went back and
reread your first post.
Only the Button and LinkButton controls fire the CommandEvent and create a CommandEventArgs object. Thus, the Button and LinkButton controls (or controls derived from them) are the only controls that will cause the Repeater to raise its ItemCommand event.
Using LutzRoeder's .NET Reflector, I took a look at the OnBubbleEvent of the Repeater to confirm that this indeed was the case. The ItemCommand event is only raised for those controls that have created a CommandEventArgs object in its original event.
Also, note that DropDownList, Checkbox and RadioButton controls (by default) do not cause a PostBack unless you set their AutoPostBack property to True.
I guess that one possibility for solving this would be to create an EnhancedRepeater class inheriting from Repeater, and overriding its OnBubbleEvent handler method to intercept the DropDownList's SelectedIndexChanged event, the Checkbox and RadioButton's CheckChanged
event, create the CommandEventArgs object and then raise the ItemCommandEvent. Not at all standard behavior, though.