This is a migrated thread and some comments may be shown as answers.

[Solved] Built-in command handling in ItemCommand

3 Answers 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 28 May 2009, 01:03 AM
If I create a CommandItemTemplate in a grid that includes commands that otherwise have handler functionality built into the grid itself (e.g. the Rebind command below):

<

 

CommandItemTemplate>

 

<

 

div align="right">

 

<

 

asp:LinkButton Style="vertical-align: bottom" ID="ClearButton" runat="server"

 

 

CommandName="Clear" Text="Clear"></asp:LinkButton> |

 

<

 

asp:Button runat="server" CommandName="Rebind" CssClass="rgRefresh"/>

 

<

 

asp:LinkButton Style="vertical-align: bottom" runat="server" CommandName="Rebind" Text="Refresh"></asp:LinkButton>

 

</

 

div>

 

</

 

CommandItemTemplate>

how do I prevent my ItemCommand handler from intercepting the default handler functionality in RadGrid being called?

 

 

protected void LogGrid_ItemCommand(object source, GridCommandEventArgs e)

 

{

 

if (e.CommandName == "Clear")

 

{

 

// here I handle my custom Clear command which works fine
return
;

 

}

// but how do I prevent the RadGrid's Rebind command handling from being lost?? I've made various attempts here with RaiseBubbleEvent with no success.  Strangely it's only the Rebind functionality that's never called.  Commands outside the CommandItemTemplate hitting this function (like DeleteCommand at the row level) still have their functionality carried out by RadGrid.

 

}

Thanks in advance for any pointers.

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 30 May 2009, 11:15 AM
Hello Mark,

Could you provide more details on what the issue is. Currently, I am not able to understand what exactly you are trying to achieve - in particular, what do you mean by preventing my ItemCommand handler from intercepting the default handler functionality in RadGrid being called , where do you call the Rebind() command apart from the button in the command template, under what circumstances do you suppose that the ItemCommand event should be thrown, etc. Could you, also, post the aspx and code-behind for the grid.

Thank you.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Mark
Top achievements
Rank 1
answered on 10 Jun 2009, 01:40 PM
RadGrid has built in Rebind ItemCommand handling for the Refresh button at the lower-right of the grid.  When I add an additional command to the command template, Clear with what I believe should be the Rebind command (see below), when ItemCommand is called, I handle Clear and return.  When I click on the Refresh button, the grid no longer refreshes.  So it seems in handling ItemCommand that I'm blocking the default handling for the Rebind command that already exists.  Do developers need to handle every ItemCommand when declaring OnItemCommand and, if so, is there a way to call the default ItemCommand handling somehow.  I'm hoping that any existing commands I don't explicitly handle when processing my additional ItemCommands (e.g. Rebind) would continue to function.  I know the Rebind ItemCommand handling is trivial to add implementation for in ItemCommand if required, but I was just wondering if I was missing something...

<

 

CommandItemTemplate>

 

<

 

div align="right">

 

<

 

asp:LinkButton Style="vertical-align: bottom" ID="ClearButton" runat="server"

 

 

CommandName="Clear" Text="Clear"></asp:LinkButton> |

 

<

 

asp:Button runat="server" CommandName="Rebind" CssClass="rgRefresh"/>

 

<

 

asp:LinkButton Style="vertical-align: bottom" runat="server" CommandName="Rebind" Text="Refresh"></asp:LinkButton>

 

</

 

div>

 

</

 

CommandItemTemplate>

 

0
Tsvetoslav
Telerik team
answered on 11 Jun 2009, 11:27 AM
Hi Mark,

Thanks for the clarification.

You need to change the command name property of the link buttons that trigger the refresh from Rebind to RebindGrid or alternatively use a server expression as follows:

<asp:Button runat="server" CommandName='<%#RadGrid.RebindGridCommandName %>' CssClass="rgRefresh" />

I hope this helps.

Best wishes,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Mark
Top achievements
Rank 1
Share this question
or