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

DeleteCommand event not firing

1 Answer 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 06 Nov 2008, 11:53 AM
In my grid I have a GridButton column with a commandname =Delete
I also have ondeletecommand=RadGridName_deleteCommand

When I click the delete button, the row is deleted, but the code in the deletecommand handler never gets executed, so how is the row deleted ?  Why is the deletecommand event handler never executed.  Heres the grid code

<telerik:RadGrid ID="RadGridImages" runat="server" GridLines="None"   
                OnItemDataBound="RadGridImages_ItemDataBound" onneeddatasource="RadGridImages_NeedDataSource"   
         AllowPaging="True" PageSize="5" Skin="Vista" Width="750px" AllowSorting="True"   
                BorderStyle="None"   
                ShowStatusBar="True" ondeletecommand="RadGridImages_DeleteCommand">  
            <MasterTableView  AutoGenerateColumns="False" DataKeyNames="ImageID">  
                <Columns> 
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName"DeleteColumn" ConfirmText="Are you sure ?"/>  
                    <telerik:GridBoundColumn DataField="ImageID" HeaderText="Image ID" SortExpression="ImageID" 
                        UniqueName="ImageID"  Visible="false">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="ArtistID" HeaderText="Artist ID" SortExpression="ArtistID" 
                        UniqueName="ArtistID"  Visible="false">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridTemplateColumn DataField="ImageThumbURL" UniqueName="ImageThumbURLColumn" HeaderText="Artist">  
                        <ItemTemplate> 
                            <asp:Image ID="ImageThumbNail" runat="server"></asp:Image> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                    <telerik:GridBoundColumn DataField="ImageDisplayFilename" HeaderText="Image" SortExpression="ImageDisplayFilename" 
                        UniqueName="ImageDisplayFilename" DataFormatString="<nobr>{0}</nobr>">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn DataField="ImageThumbURL" HeaderText="ImageThumbURL" SortExpression="ImageThumbURL" 
                        UniqueName="ImageThumbURL" Visible="False">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridTemplateColumn DataField="IsPrimaryImage" UniqueName="IsPrimaryImage" HeaderText="Primary Image ?">  
                        <ItemTemplate> 
                           <asp:Label ID="LabelPrimary" runat="server" Text="Label"></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                      
                      
                </Columns> 
                <RowIndicatorColumn Visible="False">  
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn Resizable="False" Visible="False">  
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <EditFormSettings> 
                    <PopUpSettings ScrollBars="None" /> 
                </EditFormSettings> 
            </MasterTableView> 
            <PagerStyle Mode="NextPrevAndNumeric" /> 
 
<FilterMenu Skin="Vista" EnableTheming="True">  
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</FilterMenu> 
        </telerik:RadGrid> 
  and heres the event handler in the codebehind.  Ive set a breakpoint on the firstline, but its never reached

protected void RadGridImages_DeleteCommand(object source, GridCommandEventArgs e)  
        {  
            GridDataItem item = (GridDataItem)e.Item;  
            //Get the primary key value using the DataKeyValue.       
 
            Int32 id = -1;  
            string res = string.Empty;  
            bool ok = Int32.TryParse(item.OwnerTableView.DataKeyValues[item.ItemIndex]["ImageID"].ToString(), out id);  
 
            if (ok)  
            {  
                res = imagemanager.DeleteImage(id);  
 
                if (!string.IsNullOrEmpty(res))  
                {  
                    RadGridImages.Controls.Add(new LiteralControl("Unable to delete image. Reason: " + res));  
                    e.Canceled = true;  
                }  
            }  
        } 
 Can anyone see whats going on here ?

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 07 Nov 2008, 02:15 PM
Hello mark,

To avoid multiple posts, we can continue our communication in the support ticket that you have opened on the matter.

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
mww
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or