ItemCommand event of GridView or ListView
-
GridView and ListView constrols have ItemCommand event where I can react to events generated by Button controls in the individual items. Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)? I spent several hours trying to do this but totally failed. Do you have any ideas? Any help appreciated.
-
GridView and ListView constrols have ItemCommand event where I can react to events generated by Button controls in the individual items. Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)? I spent several hours trying to do this but totally failed. Do you have any ideas? Any help appreciated.
Member 1033907 wrote:
Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)?
Yes! You can track it in ItemCreated/RowCreated. Google for 'EventBubbling' and you will get links like these: http://www.dotnetspider.com/resources/30842-Raising-An-Event-From-CheckBox-In-A-GridView.aspx[^] http://msdn.microsoft.com/en-us/library/aa719644(VS.71).aspx[^]
-
Member 1033907 wrote:
Is there a way to detect and handle events raised by non-Button controls (like CheckBox with AutoPostBack=true)?
Yes! You can track it in ItemCreated/RowCreated. Google for 'EventBubbling' and you will get links like these: http://www.dotnetspider.com/resources/30842-Raising-An-Event-From-CheckBox-In-A-GridView.aspx[^] http://msdn.microsoft.com/en-us/library/aa719644(VS.71).aspx[^]
Thanks for the reply. What exactly do you mean by using ItemCreated event in combination with event bubbling? I don't get it. I understand that I can create my own control derived from checkbox which, when checked, raises a bubble event which is then cought by the ListView. Is this what you meant? Otherwise, the first link you posted provides a fairly easy solution, without event bubbling at all.
-
Thanks for the reply. What exactly do you mean by using ItemCreated event in combination with event bubbling? I don't get it. I understand that I can create my own control derived from checkbox which, when checked, raises a bubble event which is then cought by the ListView. Is this what you meant? Otherwise, the first link you posted provides a fairly easy solution, without event bubbling at all.
Member 1033907 wrote:
Is this what you meant?
No. In ItemCreated, find the control and attach the hanlder. Though as you already saw, other approach could be done easily. It's just that event methods needs to be public or protected.
-
Member 1033907 wrote:
Is this what you meant?
No. In ItemCreated, find the control and attach the hanlder. Though as you already saw, other approach could be done easily. It's just that event methods needs to be public or protected.
So I attach the handler and in the handler, call the RaiseBubbleEvent? I'am afraid I still don't quite get it but it's more a matter of curiosity now, I can put together some working solution.