0

I am facing a weird problem with ItemCommand. I have a radGrid which is part of a User Control. This user control is added as part of another aspx page and ItemCommand is triggered and working fine when a button from GridButtonColumn is clicked. However when this user control is added within another user control, ItemCommand is not triggered at all. This RadGrid is part of RadAjaxPanel. When RadAjaxPanel is removed, ItemCommand is triggered in all scenario.

Here is how User Control looks like

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Charting" Assembly="Telerik.Web.UI" %>

<%@ Control Language="vb" AutoEventWireup="false" Codebehind="RecipientsList.ascx.vb" Inherits="Pages.Email.Controls.RecipientsList" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<table style="width:90.5%;" align="center">
<tr>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="WebBlue">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">

       <telerik:RadGrid ID="radSelect" runat="server" PageSize="20" Width="100%" FooterStyle-BackColor="AliceBlue" AllowFilteringByColumn="True" AllowSorting="True"
            AllowPaging="True" AutoGenerateColumns="False" OnUpdateCommand ="radSelect_UpdateCommand"
           ResolvedRenderMode="Classic" CellSpacing="-1"  OnItemCommand="radSelect_ItemCommand"
        OnNeedDataSource="radSelect_NeedDataSource" CssClass="RadGridMasterDiv"><PagerStyle Mode="NextPrev"  AlwaysVisible="true"></PagerStyle>

        <GroupingSettings CaseSensitive="False" />
        <MasterTableView Width="100%" AllowNaturalSort="False" DataKeyNames="EMessageID,EMsgReceiverID" ClientDataKeyNames="EMessageID">
            <HeaderStyle Font-Bold="true" />
            <CommandItemSettings ShowAddNewRecordButton="False" ShowRefreshButton="False" />
            <Columns>
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn ReadOnly="true" DataField="SubjectLine" AllowFiltering="true"  UniqueName="Subject" CurrentFilterFunction="Contains" AutoPostBackOnFilter="True" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn ReadOnly="true" DataField="DisplayStatus" UniqueName="Status" CurrentFilterFunction="Contains" AutoPostBackOnFilter="True" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn UniqueName="ResendButton" CommandName="Resend">
                </telerik:GridButtonColumn>
            </Columns>           
        </MasterTableView>           
    </telerik:RadGrid>
    <telerik:RadToolTip ID="RadToolTip1" runat="server" OffsetY="3" Position="TopCenter"
                    ShowCallout="false" Height="20px" ShowEvent="fromcode" />
</telerik:RadAjaxPanel>
</tr>
</table>

This is the page where User Control is working correctly

<%@ Register TagPrefix="header" TagName="Header" Src="../../Controls/Header.ascx" %>
<%@ Register TagPrefix="reclist" TagName="RescipentList" Src="Controls/RecipientsList.ascx" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="FailedEmails.aspx.vb" Inherits="Pages.Email.FailedEmails" smartNavigation="True" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <body MS_POSITIONING="FlowLayout" bottomMargin="10" leftMargin="5" topMargin="10" rightMargin="5">
        <form id="Form1" method="post" runat="server">
            <header:Header id="header" runat="server"></header:Header>
            <reclist:RescipentList id="rList" runat="server" ></reclist:RescipentList>
        </form>
    </body>

Here is another control where ItemCommand is not triggered. Here is the hierarchy of my controls

Header -> TabSlideOutControl -> RecipientsList which is included in .aspx page.

    <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="TabSlideOutControl.ascx.vb"
        Inherits="Pages.Controls.TabSlideOutControl" %>
        <%@ Register TagPrefix="reclist" TagName="RescipentList" Src="~/Pages/Email/Controls/RecipientsList.ascx" %>
<table>            
<tr>
                <td id="wd-Theme1">
                    <div id="divFailedEmails"  class="DIVEMAILS">
                        <reclist:RescipentList id="rList" runat="server" ></reclist:RescipentList>
                     </div>
                    </td>
            </tr>
        </table>

Can someone guide me on what could be the possible reason for ItemCommand not to work? I am clueless on how to debug this issue.

Rajan Phatak
  • 524
  • 8
  • 24

2 Answers2

0

Inside ItemCreated event of the RadGrid, register the button with RadScriptManager the register Asynchronous postback for that link button.

RadScriptManager scriptMan = RadScriptManager.GetCurrent(this);
LinkButton btn = e.Item.FindControl("yourButton") as LinkButton;
if(btn != null)
{
    btn.Click += LinkButton1_Click;
    scriptMan.RegisterAsyncPostBackControl(btn);
}

Also don't use ItemCommand here, use LinkButton1_Click and pass id as CommandArgument

Hope this helped.

Imad
  • 7,126
  • 12
  • 55
  • 112
0

Ensure you do not have nested AJAX settings (e.g., somewhere in the header or in the TabSlideOutControl control). Nesting them can cause double disposal of nodes.

Try replacing RadAjaxPanel with asp:UpdatePanel or with RadAjaxManager/RadAjaxManagerProxy setting.

Ensure the overall HTML of the page is valid in case there is a problem with that which breaks AJAX requests.

Make sure there are no script or server-side errors during execution.

rdmptn
  • 5,413
  • 1
  • 16
  • 29