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

master detail problem

1 Answer 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 26 Jul 2009, 04:57 PM
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

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 27 Jul 2009, 06:17 AM
Hi,

You can try out the following code to access the value from the parent row when its child table is in Insert mode:
c#:
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; 
            
        } 
    }     

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