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

Ajaxified Dynamic RadGrid GirdEditCommandColumn never fires Update or Cancel command

3 Answers 93 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Owen
Top achievements
Rank 1
Owen asked on 17 Jan 2014, 07:34 PM
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" />

CS
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;
    productGrid.MasterTableView.Columns.Add(checkColumn);
 
    GridBoundColumn boundColumn = new GridBoundColumn();
    boundColumn.DataField = "ProductName";
    boundColumn.HeaderText = "Product Name";
    boundColumn.ReadOnly = true;
    productGrid.MasterTableView.Columns.Add(boundColumn);
 
    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;
    productGrid.MasterTableView.Columns.Add(numericColumn);
        
        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;
    productGrid.MasterTableView.Columns.Add(boundColumn);
 
        boundColumn = new GridBoundColumn();
    boundColumn.DataField = "ProductID";
    boundColumn.ReadOnly = true;
    boundColumn.Display = false;
    productGrid.MasterTableView.Columns.Add(boundColumn);
 
    GridEditCommandColumn editColumn = new GridEditCommandColumn();
    editColumn.ItemStyle.Width = Unit.Pixel(75);
    editColumn.UniqueName = "Edit";
    editColumn.EditText = "Add/Edit Fee";
    productGrid.MasterTableView.Columns.Add(editColumn);
 
    return productGrid;
}

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Jan 2014, 06:40 AM
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.

Thanks,
Princy
0
Owen
Top achievements
Rank 1
answered on 18 Jan 2014, 08:15 AM
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.
0
Maria Ilieva
Telerik team
answered on 22 Jan 2014, 12:38 PM
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.


Regards,
Maria Ilieva
Telerik
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.
Tags
Grid
Asked by
Owen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Owen
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or