ItemCommand for DetailTables

6 posts, 0 answers
  1. Lucania
    Lucania  avatar
    65 posts
    Member since:
    May 2011

    Posted 06 Jun 2012 Link to this post

    I have the following grid, but have found that the Itemcommand event is not fired when I click btnEdit2 on the detail table. It does fire correctly when I click the button on the master table. Do I need to do anything else to get this to work?

    Thanks

    <telerik:RadGrid ID="testgrid" runat="server" OnItemCommand="ItemCommand" DataSourceID="dsAppointments">
        <MasterTableView Name="Master" DataSourceID="dsAppointments" DataKeyNames="TaskID" EditMode="PopUp" AllowAutomaticUpdates="true" CommandItemDisplay="Top">
            <CommandItemSettings ShowAddNewRecordButton="false" ShowExportToCsvButton="false" ShowRefreshButton="false" />
            <Columns>
                <telerik:GridTemplateColumn UniqueName="Edit">
                    <ItemTemplate>
                        <asp:LinkButton ID="btnEdit1" runat="server"
                            CommandName="JumpTo" CommandArgument='<%# Eval("TaskID") %>' CausesValidation="false"
                            PostBackUrl="~/Default.aspx">
                            Edit
                        </asp:LinkButton>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
            <DetailTables>
                <telerik:GridTableView Name="Detail" DataSourceID="dsAttendees" CommandItemDisplay="None" DataKeyNames="TaskID" TableLayout="Auto" HorizontalAlign="NotSet" ShowHeader="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true">
                    <ParentTableRelation>
                        <telerik:GridRelationFields MasterKeyField="TaskID" DetailKeyField="TaskID" />
                    </ParentTableRelation>
                    <Columns>
                        <telerik:GridTemplateColumn UniqueName="Edit">
                            <ItemTemplate>
                                <asp:LinkButton ID="btnEdit2" runat="server"
                                    CommandName="JumpTo" CommandArgument='<%# Eval("TaskID") %>' CausesValidation="false"
                                    PostBackUrl="~/Default.aspx">
                                    Edit
                                </asp:LinkButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>
        </MasterTableView>
    </telerik:RadGrid>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Jun 2012 Link to this post

    Hello Ross,

    Try accessing the DetailTable using its Name property.
    aspx:
    <DetailTables>
      <telerik:GridTableView Name="DetailTable1">
        . . .
    </DetailTables>
    C#:
    protected void RadGrid2_ItemCommand(object sender, GridCommandEventArgs e)
     if (e.CommandName == "JumpTo" && e.Item.OwnerTableView.Name == "DetailTable1")
     {
     }
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lucania
    Lucania  avatar
    65 posts
    Member since:
    May 2011

    Posted 14 Jun 2012 Link to this post

    Hi Shinu,

    As you can see in my example, the detail table does have a name, the problem is the ItemCommand event function never gets called for the detail table, so the code you suggest never gets executed. Note:

    1. The event IS called for the master table, and OwnerTableView.Name = "Master" as expected;
    2. The event IS NOT called for the detail table;
    3. The postback DOES occur for both master & detail, and transfers as expected to the LinkButton's PostBackUrl

    Thanks

    ROSCO

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Jun 2012 Link to this post

    Hi Ross,

    I was able to observe this behavior on setting the PostBackUrl property of LinkButton. On specifying Page2.aspx causes the page that contains the LinkButton control to post to Page2.aspx. If you do not specify a value for the PostBackUrl property, the page posts back to itself. Then you can find the ItemCommand event firing for the detailtable. Hope this helps.

    Thanks,
    Shinu.
  6. Saquib
    Saquib avatar
    18 posts
    Member since:
    Aug 2011

    Posted 21 Mar 2013 Link to this post

    I am struggling with the same problem. Ross, have you found the solution yet. Can somebody help me find the solution please. 
    In my case DetailTable was firing ItemCommand in Sitefinity 3.7 but after merging to Sitefinity 5, it stopped working. 

    Shinu: I don't have PostBackUrl of my LinkButton set to anything. 

    Thank you
    Saquib
  7. Ryan Strand
    Ryan Strand avatar
    1 posts
    Member since:
    Apr 2010

    Posted 16 Jul 2014 in reply to Saquib Link to this post

    Hello Saquib,

    I am experiencing this same issue and have not yet found a solution.  Did you ever resolve this issue?

    Regards,
    Ryan
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017