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

ItemCommand for DetailTables

5 Answers 381 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lucania
Top achievements
Rank 1
Lucania asked on 06 Jun 2012, 06:24 AM
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>

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 06 Jun 2012, 06:48 AM
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.
0
Lucania
Top achievements
Rank 1
answered on 14 Jun 2012, 11:05 PM
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

0
Shinu
Top achievements
Rank 2
answered on 15 Jun 2012, 05:00 AM
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.
0
Saquib
Top achievements
Rank 1
answered on 21 Mar 2013, 07:07 PM
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
0
Ryan Strand
Top achievements
Rank 1
answered on 16 Jul 2014, 07:13 PM
Hello Saquib,

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

Regards,
Ryan
Tags
Grid
Asked by
Lucania
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Lucania
Top achievements
Rank 1
Saquib
Top achievements
Rank 1
Ryan Strand
Top achievements
Rank 1
Share this question
or