In your user control class, override OnBubbleEvent(). If you return true, you will stop the "bubble up" to the parent controls.
protected override bool OnBubbleEvent(object source, EventArgs args)
{
//handled
return true;
//uncomment line below to bubble up (unhandled)
//return base.OnBubbleEvent(source, args);
}
Another somewhat neat thing to think about that I found while tinkering on this, which might be useful in some instances... you can change the command name that 'bubbles up' in the control heirachy as well. In your child user control, use OnCommand, rather than Onclick.
So, say you have a button in your user control, change the code from this:
<asp:button id="mySpecialButton"
onClick="mySpecialButton_OnClick" runat="server">
to this:
<asp:Button id="mySpecialButton"
CommandName="mySpecialCommand"
CommandArgument="myArgument"
OnCommand="mySpecialButton_Command"
runat="server"/>
then in the codebehind,
protected void mySpecialButton_Command(object sender, CommandEventArgs e)
{
RaiseBubbleEvent(this, new CommandEventArgs("Handled", e));
}
Thus, in your parent control's ItemCommand handler you will then get this new command name rather than the original command name from the child control, which you can do with as you see fit.