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

grid hierarchy problem

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mww
Top achievements
Rank 1
mww asked on 05 Feb 2009, 01:54 PM
I have a grid with a master and detail table.  The master table has several rows.  When I click a row to expand the detail table, in the ItemDataBound Event I have some code that populates a dropdown in the detail table, as below

if ("ArtistCategories".Equals(e.Item.OwnerTableView.Name))  
            {  
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
                {  
 
                    GridDataItem dataitem = e.Item.OwnerTableView.ParentItem;  
                    Hashtable values = new Hashtable();  
                    dataitem.ExtractValues(values);  
                    object Objgenre = values["Genre"];    
 
                      
                    GridEditableItem _item = (GridEditableItem)e.Item;  
                    Telerik.Web.UI.RadComboBox cb = (Telerik.Web.UI.RadComboBox)_item["ArtistCategory"].FindControl("RadComboBoxCategories");  
 
                    string genre = Objgenre.ToString();  
                    cb.DataSource = lookupmanager.CategoryByGenre(genre, this.RadComboBoxType.SelectedValue);  
                    cb.DataTextField = "Category";  
                    cb.DataValueField = "Category";  
                    cb.DataBind();  
 
                    try  
                    {  
                        Studio1DBObjects.SecondaryCategory sg = (Studio1DBObjects.SecondaryCategory)e.Item.DataItem;  
                        string category = sg.Category;  
                        int index = cb.FindItemIndexByValue(category);  
                        cb.SelectedIndex = index;  
                    }  
                    catch (Exception ex)  
                    {  
                        //  
                    }  
 
                }  
            } 

The contents of the drop down are determined by 2 values, a 'type' which is a drop down on the main page, and 'genre' which is a column in the master table in the grid.  After searching the forums, the only method I could find to obtain this value from the master table is by using a hashtable, like so

Hashtable values = new Hashtable();  
                    dataitem.ExtractValues(values);  
                    object Objgenre = values["Genre"];  

After stepping through the code, the hash table is always empty (its count is zero), yet the master table has data.  How Can I obtain the data I need from the selected row in the master table ??  Is there another way ?

1 Answer, 1 is accepted

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

You can try out the following code to access the MasterTableView item when an item in the DetailTable is in EditMode:
cs:
if ("ArtistCategories".Equals(e.Item.OwnerTableView.Name))   
            {   
                if (e.Item is GridEditableItem && e.Item.IsInEditMode)   
                {   
  
                    GridEditableItem _item = (GridEditableItem)e.Item;                     
                    GridDataItem parentItem = (GridDataItem)editItem.OwnerTableView.ParentItem; 
                    string string = parentItem["Genre"].Text; 
   
                  } 
             } 
   
  

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