Grid on Dynamic User Control not firing GridEditCommandColumn

2 posts, 0 answers
  1. Tim
    Tim avatar
    1 posts
    Member since:
    May 2016

    Posted 31 May 2016 Link to this post

    This was working just fine until I decided to move the accordion onto the main page instead of having it on the user control.

    The GridEditCommandColumn is not firing any events, even the NeedDataSource event.

    The grid appears in a ModalPopUp, which worked fine until I moved the accordion to the main page.

    I forced the PopUp to stay visible to check the grid and it is not re-binding, and not hitting any events when the GridEditCommandColumn is clicked.

    Here is the main aspx page:

    <%@ Register src="../../Common/Controls/SiteAdmin/ServiceType/ucServiceTypes.ascx" tagname="ucServiceTypes" tagprefix="uc1" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ajax:Accordion ID="Accordion1" runat="server" HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected"
                    ContentCssClass="accordionContent" SelectedIndex="-1" FadeTransitions="true"
                    SuppressHeaderPostbacks="true" TransitionDuration="250" FramesPerSecond="40"
                    RequireOpenedPane="false" AutoSize="None" Width="100%">


    The the code behind for the main aspx page:

    protected void Page_Load(object sender, System.EventArgs e)
    private void LoadUserControls()
        string path = "~/Common/Controls/SiteAdmin/ServiceType/ucServiceTypes.ascx";
        Common_Controls_SiteAdmin_ServiceType_ucServiceTypes uc;
        DataTable dt = GetServiceTypes();
        for (int i = 0; i < dt.Rows.Count; i++)
            uc = LoadControl(path) as Common_Controls_SiteAdmin_ServiceType_ucServiceTypes;
            uc.ID = "uc" + dt.Rows[i]["Name"].ToString();
            uc.ServiceTypeID.Value = dt.Rows[i]["ServiceTypeID"].ToString();
            Literal lit = new Literal();
            AccordionPane pane = new AccordionPane();
            pane.ID = "pane" + i.ToString();
            lit = new Literal();
            lit.Text = dt.Rows[i]["Name"].ToString();


    Now for the user control:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucServiceTypes.ascx.cs" Inherits="Common_Controls_SiteAdmin_ServiceType_ucServiceTypes" %>
    <asp:HiddenField ID="hdnServiceTypeID" runat="server" />
    <asp:HiddenField ID="hdnServiceDefID" runat="server" />
    <asp:Panel ID="pnlView" runat="server" Style="display: none;" CssClass="modalPopUpPanel">
        <div style="height: 500px; overflow: auto;">
            <asp:HiddenField ID="hdnViewPopUp" runat="server" />
            <h3 style="text-align: center;" id="header">
                <asp:Label ID="lblServiceDefName" runat="server"></asp:Label></h3>    
            <table style="width: 100%">
                    <td style="text-align: left">
        <telerik:RadGrid ID="rgServiceOptionDefs" runat="server" AutoGenerateColumns="False"
            ResolvedRenderMode="Classic" AllowAutomaticUpdates="false" AllowAutomaticInserts="false"
            OnItemCommand="rgServiceOptionDefs_ItemCommand" OnItemCreated="rgServiceOptionDefs_ItemCreated"
            OnNeedDataSource="rgServiceOptionDefs_NeedDataSource" OnItemDataBound="rgServiceOptionDefs_ItemDataBound"
            OnEditCommand="rgServiceOptionDefs_EditCommand" OnPreRender="rgServiceOptionDefs_PreRender"
            <MasterTableView DataKeyNames="ServiceOptionDefID" EditMode="InPlace" CommandItemDisplay="Top">
                    <telerik:GridEditCommandColumn />
                    <telerik:GridTemplateColumn HeaderText="Name" UniqueName="Name">
                            <asp:Label ID="lblName" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Name")%>'></asp:Label>
                            <asp:TextBox ID="txtName" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.Name")%>'></asp:TextBox>
                        <ItemStyle VerticalAlign="Top" HorizontalAlign="Center" />
                    <telerik:GridTemplateColumn HeaderText="Type" UniqueName="Type">
                            <asp:Label ID="lblType" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.InputType")%>'></asp:Label>
                            <telerik:RadListBox ID="ddlType" runat="server"></telerik:RadListBox>
                        <ItemStyle VerticalAlign="Top" HorizontalAlign="Center" />
            <p style="text-align: center;">
                <asp:Button ID="btnCloseView" CssClass="Button" runat="server" Text="Close" CausesValidation="false" />
    <ajax:ModalPopupExtender ID="mpeView" runat="server" TargetControlID="hdnViewPopUp" PopupControlID="pnlView"
        CancelControlID="btnCloseView" BackgroundCssClass="backgroundColor" DropShadow="true"




    protected void rgServiceOptionDefs_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        if (!string.IsNullOrEmpty(hdnServiceDefID.Value))
            int ServiceDefID = int.Parse(hdnServiceDefID.Value);
            DataTable dt = GetServiceOptionDefs(ServiceDefID);
            rgServiceOptionDefs.DataSource = dt;
    protected void rgServiceOptionDefs_ItemCreated(object sender, GridItemEventArgs e)
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            GridEditableItem editedItem = e.Item as GridEditableItem;
        else if (e.Item is GridDataItem)
            GridDataItem dataItem = e.Item as GridDataItem;
    protected void rgServiceOptionDefs_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridDataItem && !e.Item.IsInEditMode)
        else if ((e.Item is GridDataItem || e.Item is GridEditableItem) && e.Item.IsInEditMode)
        if (e.Item is GridEditFormInsertItem || e.Item is GridDataInsertItem)
            // insert item
    protected void rgServiceOptionDefs_ItemCommand(object sender, GridCommandEventArgs e)
    protected void rgServiceOptionDefs_UpdateCommand(object sender, GridCommandEventArgs e)
        GridEditableItem item = e.Item as GridEditableItem;
    protected void rgServiceOptionDefs_EditCommand(object sender, GridCommandEventArgs e)
    protected void rgServiceOptionDefs_PreRender(object sender, EventArgs e)
        //if (!string.IsNullOrEmpty(hdnServiceDefID.Value))
        //    mpeView.Show();


    If anyone needs more information, I will provide it.

    But I am at an end here trying to find out why this is happening.

    And as can be seen, I've tried a few events.


  2. Viktor Tachev
    Viktor Tachev avatar
    2499 posts

    Posted 01 Jun 2016 Link to this post

    Hi Tim,

    Please note that the AjaxControlToolkit can break the functionality of Telerik controls. Check the following thread that describes the issue in more detail.

    In place of the Accordion control you can use RadPanelBar. Check out the following example that shows the control in action:

    Viktor Tachev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top