grid hierarchy problem

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

    Posted 05 Feb 2009 Link to this post

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

    Posted 06 Feb 2009 Link to this post

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