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

What event do I use to bind to the Insert command item?

3 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Software asked on 26 Feb 2009, 08:24 PM
I've got a RadGrid with an "Add" link button at the bottom in the CommandItem.  What event is fired off when the user clicks that button?  I've got an ItemCommand method that does things for "Edit", "RowClick", etc. but clicking on this button does not trigger that event...  Also, on the other side of the CommandItem bar is the "Refresh".  Is that tied to an event as well?  Can't find either of those.  Can someone help me out?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 Feb 2009, 06:05 AM
Hi Eddie,

The ItemCommand event will fire when any button is clicked in the RadGrid control. You can check the e.CommandName in order to differentiate which button is clicked. I have tried this and its working for me. See the example below.

CS:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    if (e.CommandName == "InitInsert"
    { 
        // Clicked on Add new Record 
    } 
    else if (e.CommandName == "RebindGrid"
    { 
        // Clicked on Refresh 
    } 

Thanks,
Shinu.
0
Software
Top achievements
Rank 1
answered on 27 Feb 2009, 06:18 PM
Thanks Shinu, I was checking e.Item is GridDataItem right at the beginning of the method, which obviously wouldn't work for the GridCommandItem...
0
Sebastian
Telerik team
answered on 02 Mar 2009, 09:39 AM
Hi Eddie,

Indeed the item passed in the ItemCommand handler will be GridCommandItem since the buttons which reside in it triggered the action. More information about how to set predefined values for column editors on init insert and the event bubbling mechanism of RadGrid for ASP.NET AJAX you can find below:

http://www.telerik.com/help/aspnet-ajax/apiforcontrolling_net2.html
http://www.telerik.com/help/aspnet-ajax/grdcommandreference.html

Kind regards,
Sebastian
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
Software
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Software
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or