master detail problem

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

    Posted 26 Jul 2009 Link to this post

    I have a grid with a master and detail table.  When I insert a row in the detail table, I need to get a value from the master table (not the datakey value - one of the columns)

    How can I do this ?

    in the InsertCommand event I have this code

    if ("ArtistTypeSWF".Equals(e.Item.OwnerTableView.Name))  -- check for the detail table
                    Telerik.Web.UI.GridEditFormInsertItem editinsertitem = (Telerik.Web.UI.GridEditFormInsertItem)e.Item;  
                    GridDataItem dataitem = e.Item.OwnerTableView.ParentItem;  
                    DBObjects.ArtistType at = (DBObjects.ArtistType)dataitem.DataItem;  
                    ----  at is null, I need to get the data from one of the master table columns here
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 27 Jul 2009 Link to this post


    You can try out the following code to access the value from the parent row when its child table is in Insert mode:
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
           if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.Name == "Detail" && e.Item.OwnerTableView.IsItemInserted)   
                GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item; 
                string strtxt = item.OwnerTableView.ParentItem["ColumnUniqueName"].Text; 

Back to Top