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

[Solved] cant edit nested hierarchy rows

2 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mac
Top achievements
Rank 1
mac asked on 20 Jun 2008, 04:42 PM
 am experiencing difficulty doing any edits/inserts/deletes on child tables within the grid obj.
using the sample provided that displays hierarchal tables. http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/Hierarchy/ThreeLevel/DefaultCS.aspx
i removed the third child as it was redundant to the issue - you will note the allowAutomaticUpdates is enabled, along with the gridEditCommanColumn.  thoughts on why this would not work?
 <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadGrid1">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
        <telerik:RadGrid ID="RadGrid1" Skin="Office2007" ShowGroupPanel="True" ShowStatusBar="True" 
            runat="server" DataSourceID="SqlDataSource1" Width="95%" AutoGenerateColumns="False" 
            PageSize="3" AllowSorting="True" AllowPaging="True" GridLines="None">  
            <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle> 
            <MasterTableView Width="100%" DataSourceID="SqlDataSource1"   
            DataKeyNames="CustomerID" AllowMultiColumnSorting="True">  
                <DetailTables> 
                    <telerik:GridTableView AllowAutomaticUpdates="true" DataSourceID="SqlDataSource2"   
                    Width="100%" runat="server">  
                        <ParentTableRelation> 
                            <telerik:GridRelationFields DetailKeyField="CustomerID"   
                            MasterKeyField="CustomerID" /> 
                        </ParentTableRelation> 
                        <Columns> 
                        <telerik:GridEditCommandColumn ButtonType="PushButton">  
                        </telerik:GridEditCommandColumn> 
                            <telerik:GridBoundColumn SortExpression="OrderID" HeaderText="OrderID" DataField="OrderID" UniqueName="OrderID">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn SortExpression="OrderDate" HeaderText="Date Ordered" DataField="OrderDate" UniqueName="OrderDate">  
                            </telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn SortExpression="EmployeeID" HeaderText="EmployeeID" DataField="EmployeeID" UniqueName="EmployeeID">  
                            </telerik:GridBoundColumn> 
                        </Columns> 
                    </telerik:GridTableView> 
                </DetailTables> 
                <Columns> 
                    <telerik:GridBoundColumn SortExpression="CustomerID" HeaderText="CustomerID" DataField="CustomerID" UniqueName="CustomerID">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn SortExpression="ContactName" HeaderText="Contact Name" DataField="ContactName" UniqueName="ContactName">  
                    </telerik:GridBoundColumn> 
                    <telerik:GridBoundColumn SortExpression="CompanyName" HeaderText="Company" DataField="CompanyName" UniqueName="CompanyName">  
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
            <ClientSettings ReorderColumnsOnClient="True" AllowDragToGroup="True" AllowColumnsReorder="True">  
                <Resizing AllowRowResize="True" AllowColumnResize="True"></Resizing> 
            </ClientSettings> 
        </telerik:RadGrid>&nbsp;<br /> 
        <br /> 
          
<asp:SqlDataSource ID="SqlDataSource1"   
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" 
            ProviderName="System.Data.SqlClient" 
            SelectCommand="SELECT * FROM Customers" runat="server"></asp:SqlDataSource> 
<asp:SqlDataSource ID="SqlDataSource2"   
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"   
            SelectCommand="SELECT * FROM [Orders] WHERE ([CustomerID] = @CustomerID)" runat="server"   
            DeleteCommand="DELETE FROM [Orders] WHERE [OrderID] = @OrderID"   
            UpdateCommand="UPDATE [Orders] SET  [EmployeeID] = @EmployeeID, [OrderDate] = @OrderDate   
            WHERE [OrderID] = @OrderID"> 
            <SelectParameters> 
                <asp:SessionParameter Name="CustomerID" SessionField="CustomerID" Type="String" /> 
            </SelectParameters> 
    <DeleteParameters> 
        <asp:Parameter Name="OrderID" Type="Int32" /> 
    </DeleteParameters> 
    <UpdateParameters> 
        <asp:Parameter Name="EmployeeID" Type="Int32" /> 
        <asp:Parameter Name="OrderDate" Type="DateTime" /> 
        <asp:Parameter Name="OrderID" Type="Int32" /> 
    </UpdateParameters> 
     
        </asp:SqlDataSource> 
        </asp:Content> 

2 Answers, 1 is accepted

Sort by
0
mac
Top achievements
Rank 1
answered on 20 Jun 2008, 05:03 PM
duhhh...
don't forget to add the DataKeyNames to the GridTableView you are editing on.

<telerik:GridTableView 

DataKeyNames="your Key ID"

 VirtualItemCount="100"   

                            CommandItemDisplay="TopAndBottom"    
                            DataSourceID="AllApps"   
                            runat="server" AutoGenerateColumns="False"
0
Princy
Top achievements
Rank 2
answered on 23 Jun 2008, 05:46 AM
Hi Mac,

You can also go through the following demo link.
Update/Insert/Delete in hierarchy

Princy.
Tags
Grid
Asked by
mac
Top achievements
Rank 1
Answers by
mac
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or