Ajaxified Dynamic RadGrid GirdEditCommandColumn never fires Update or Cancel command

4 posts, 0 answers
  1. Owen
    Owen avatar
    12 posts
    Member since:
    May 2013

    Posted 17 Jan 2014 Link to this post

    I have grids populating a RadPanelBar that are created entirely from the codebehind using advanced data binding. I have a GridEditCommandColumn in this grid. When I click "Edit", ItemCommand is fired followed by EditCommand. At this time, the column displays "Update Cancel". Clicking either of these causes a postback, but ItemCommand does not fire. Nor does UpdateCommand or CancelCommand. As you can see in my .cs, I've attached every command handler I could find trying to find something triggered when I click Update or Cancel with no luck. Any help would be great.

    ASPX <!-- 2013.3.1114.40 -->
    <telerik:RadPanelBar runat="server" ID="ClientProductPanels" Width="100%" AllowCollapseAllItems="false" ExpandMode="SingleExpandedItem" />

    private RadGrid PopulatePanelGrid(string referrer)
        RadGrid productGrid = new RadGrid();
        productGrid.AllowPaging = false;
        productGrid.AllowSorting = false;
        productGrid.AllowAutomaticInserts = true;
        productGrid.AllowAutomaticDeletes = true;
        productGrid.AllowAutomaticUpdates = true;
        productGrid.AutoGenerateEditColumn = true;
        productGrid.AutoGenerateDeleteColumn = true;
        productGrid.MasterTableView.AutoGenerateColumns = false;
        productGrid.MasterTableView.EditMode = GridEditMode.InPlace;
        productGrid.ID = referrer;
        productGrid.DeleteCommand += new GridCommandEventHandler(productGrid_DeleteCommand);
        productGrid.CancelCommand += new GridCommandEventHandler(productGrid_CancelCommand);
        productGrid.BatchEditCommand += new GridBatchEditEventHandler(productGrid_BatchEditCommand);
        productGrid.ItemDeleted += new GridDeletedEventHandler(productGrid_ItemDeleted);
        productGrid.ItemCommand += new GridCommandEventHandler(productGrid_ItemCommand);
        productGrid.ItemEvent += new GridItemEventHandler(productGrid_ItemEvent);
        productGrid.ItemInserted += new GridInsertedEventHandler(productGrid_ItemInserted);
        productGrid.ItemUpdated += new GridUpdatedEventHandler(productGrid_ItemUpdated);
        productGrid.InsertCommand += new GridCommandEventHandler(productGrid_InsertCommand);
        productGrid.EditCommand += new GridCommandEventHandler(productGrid_EditCommand);
        productGrid.UpdateCommand += new GridCommandEventHandler(productGrid_UpdateCommand);
        productGrid.ItemDataBound += new GridItemEventHandler(productGrid_ItemDataBound);
        productGrid.ItemCreated += new GridItemEventHandler(productGrid_ItemCreated);
        productGrid.NeedDataSource += new GridNeedDataSourceEventHandler(productGrid_NeedDataSource);
            GridCheckBoxColumn checkColumn = new GridCheckBoxColumn();
        checkColumn.UniqueName = "Checked";
        checkColumn.DataField = "Selected";
        checkColumn.ReadOnly = true;
        checkColumn.HeaderStyle.Width = Unit.Pixel(20);
        checkColumn.ItemStyle.Width = Unit.Pixel(20);
        checkColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
        GridBoundColumn boundColumn = new GridBoundColumn();
        boundColumn.DataField = "ProductName";
        boundColumn.HeaderText = "Product Name";
        boundColumn.ReadOnly = true;
        GridNumericColumn numericColumn = new GridNumericColumn();
        numericColumn.DataField = "Fee";
        numericColumn.HeaderText = "Fee";
        numericColumn.UniqueName = "Fee";
        numericColumn.DataFormatString = "{0:C}";
        numericColumn.DecimalDigits = 2;
        numericColumn.MaxLength = 7;
        numericColumn.NumericType = NumericType.Currency;
        numericColumn.HeaderStyle.Width = Unit.Pixel(110);
        numericColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
        numericColumn.ItemStyle.Width = Unit.Pixel(110);
        numericColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
            boundColumn = new GridBoundColumn();
        boundColumn.DataField = "AverageFee";
        boundColumn.HeaderText = "Average Fee";
        boundColumn.DataFormatString = "{0:C}";
        boundColumn.ReadOnly = true;
        boundColumn.HeaderStyle.Width = Unit.Pixel(110);
        boundColumn.HeaderStyle.HorizontalAlign = HorizontalAlign.Right;
        boundColumn.ItemStyle.Width = Unit.Pixel(110);
        boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Right;
            boundColumn = new GridBoundColumn();
        boundColumn.DataField = "ProductID";
        boundColumn.ReadOnly = true;
        boundColumn.Display = false;
        GridEditCommandColumn editColumn = new GridEditCommandColumn();
        editColumn.ItemStyle.Width = Unit.Pixel(75);
        editColumn.UniqueName = "Edit";
        editColumn.EditText = "Add/Edit Fee";
        return productGrid;

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Jan 2014 Link to this post

    Hi Owen,

    I have noticed that you have set AllowAutomaticUpdates="true", when you are performing Manual CRUD Operations we don't set properties such as AllowAutomaticUpdates, AllowAutomaticInserts and AllowAutomaticDeletes. These are used when you have Automatic operations that don't use any UpdateCommand or InsertCommand events.
    So please set it to false and see if it makes any difference.

  3. DevCraft R3 2016 release webinar banner
  4. Owen
    Owen avatar
    12 posts
    Member since:
    May 2013

    Posted 18 Jan 2014 Link to this post

    Princy, thank you for your response. I have tried auto set to true, false, and default with no change. Basically, it seems that the href=" javascript: __doPostback..." is prevented from firing once "Edit" changes to "Update Cancel". If I override the raise Post Back, it never gets hit on the update event. It always gets hit on an edit or delete.
  5. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 22 Jan 2014 Link to this post

    Hello Owen,

    Could you please elaborate a bit more on the exact scenario you are implementing? Does the "PopulatePanelGrid" method called in Page_Init event? Note that declaring the RadGrid control this way it should be called exactly in Page_Init.

    Maria Ilieva
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top