DeleteCommand event not firing

2 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 06 Nov 2008 Link to this post

    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"   
                    ShowStatusBar="True" ondeletecommand="RadGridImages_DeleteCommand">  
                <MasterTableView  AutoGenerateColumns="False" DataKeyNames="ImageID">  
                        <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 DataField="ArtistID" HeaderText="Artist ID" SortExpression="ArtistID" 
                            UniqueName="ArtistID"  Visible="false">  
                        <telerik:GridTemplateColumn DataField="ImageThumbURL" UniqueName="ImageThumbURLColumn" HeaderText="Artist">  
                                <asp:Image ID="ImageThumbNail" runat="server"></asp:Image> 
                        <telerik:GridBoundColumn DataField="ImageDisplayFilename" HeaderText="Image" SortExpression="ImageDisplayFilename" 
                            UniqueName="ImageDisplayFilename" DataFormatString="<nobr>{0}</nobr>">  
                        <telerik:GridBoundColumn DataField="ImageThumbURL" HeaderText="ImageThumbURL" SortExpression="ImageThumbURL" 
                            UniqueName="ImageThumbURL" Visible="False">  
                        <telerik:GridTemplateColumn DataField="IsPrimaryImage" UniqueName="IsPrimaryImage" HeaderText="Primary Image ?">  
                               <asp:Label ID="LabelPrimary" runat="server" Text="Label"></asp:Label> 
                    <RowIndicatorColumn Visible="False">  
                        <HeaderStyle Width="20px" /> 
                    <ExpandCollapseColumn Resizable="False" Visible="False">  
                        <HeaderStyle Width="20px" /> 
                        <PopUpSettings ScrollBars="None" /> 
                <PagerStyle Mode="NextPrevAndNumeric" /> 
    <FilterMenu Skin="Vista" EnableTheming="True">  
    <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
      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 ?
  2. Yavor
    Yavor avatar
    11 posts

    Posted 07 Nov 2008 Link to this post

    Hello mark,

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

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. DevCraft R3 2016 release webinar banner
Back to Top