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

hierarchical data

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 04 Feb 2009, 03:15 PM
I have a grid with one master and one detail table. Ive included the toolbar at the top which allows me to include the program logic for adding new records to the master table, but how can I provide the same functionality for the detail table ?  (as well as update and delete)

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Feb 2009, 06:21 AM
Hello Mark,

You can place  a similar ToolBar in the CommandItemTemplate of the DetailTable as well and check for the Name property of the owner table to perform insert/update/delete operations as shown below:
aspx:
 
<telerik:RadGrid  ID="RadGrid2" runat="server" OnItemCommand="RadGrid2_ItemCommand" OnNeedDataSource="RadGrid2_NeedDataSource" >   
      <MasterTableView  CommandItemDisplay="Top" EditMode="InPlace" Name="Master">   
         <CommandItemTemplate>   
                <telerik:RadToolBar ID="RadToolBar1" Skin="Vista" runat="server" OnButtonClick="RadToolBar1_ButtonClick">                   
                    <Items>   
                       <telerik:RadToolBarButton Text="Update" CommandName="UpdateEdited" ImageUrl="~/Update.gif" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'></telerik:RadToolBarButton>                     
                      .....  
                    </Items>                      
                </telerik:RadToolBar>   
            </CommandItemTemplate>   
       <DetailTables>          
        <telerik:GridTableView EditMode="InPlace" DataSourceID="SqlDataSource1" CommandItemDisplay="Top" Name="Detail" runat="server" >   
          <CommandItemTemplate>   
                <telerik:RadToolBar ID="RadToolBar1" Skin="Vista" runat="server" OnButtonClick="RadToolBar1_ButtonClick">                   
                        <Items>   
                           <telerik:RadToolBarButton Text="Update" CommandName="UpdateEdited" ImageUrl="~/Update.gif" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'></telerik:RadToolBarButton>                                
                      ....     
                  </Items>                      
            </telerik:RadToolBar>   
        </CommandItemTemplate>   
       ....   
 

cs:
 
 protected void RadGrid2_ItemCommand(object source, GridCommandEventArgs e)  
    {  
        if (e.CommandName == "UpdateEdited")  
        {  
            if (e.Item.OwnerTableView.Name == "Detail")  
            {  
                     //Perform Insert to DB here  
            }               
        }    
       //Similarly you can perform the update and delete operations    
  }    
 

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