hierarchical data

2 posts, 0 answers
  1. mww
    mww avatar
    257 posts
    Member since:
    Sep 2012

    Posted 04 Feb 2009 Link to this post

    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)
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Feb 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top