Master/Detail Parent ID

7 posts, 0 answers
  1. Pouya ir
    Pouya ir avatar
    13 posts
    Member since:
    Aug 2009

    Posted 17 Aug 2009 Link to this post

    hi
    i have 3 table:  1- Master table    2- Detail table(0)    3- Detail table(1)
    when i want update detailTable(0) i can:

    int ParentId = RadGrid1.MasterTableView.DataKeyValues[

    int.Parse(e.Item.OwnerTableView.ParentItem.ItemIndexHierarchical)]["Id"].ToString();

    but when i want update DetailTable(1) i can not use this code :

     

    int ParentId = RadGrid1.MasterTableView.DetailTables[0].DataKeyValues[int.Parse(e.Item.OwnerTableView.ParentItem.ItemIndexHierarchical)][

    "Id"].ToString();
        // erro ocured and i can not use :((

    maybe my method completly is uncurrect.

     

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Aug 2009 Link to this post

    Hello,

    Check out the following code that I tried to retrieve the DataKeyValues for the third level's parnet item in a hierarchial grid:
    c#:
    string ParentId = item.OwnerTableView.ParentItem.GetDataKeyValue("Id").ToString(); 

    Hope this helps... :)
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pouya ir
    Pouya ir avatar
    13 posts
    Member since:
    Aug 2009

    Posted 18 Aug 2009 Link to this post

    tnxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ! ! !  ! !
  5. illumination
    illumination avatar
    85 posts
    Member since:
    May 2008

    Posted 16 Jun 2011 Link to this post

    How do I grab this parent ID and put in a textbox in editmode of the detail table?
  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jun 2011 Link to this post

    Hello Illumination,

    Try the following code snippet in ItemDataBound event to get the parent ID in edit mode. Hope this helps.

    C#:
    protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
       {
           if (e.Item is GridEditableItem && e.Item.IsInEditMode && e.Item.OwnerTableView.Name == "DetailTable1")
           {
               GridEditableItem item = (GridEditableItem)e.Item;
               string customerId1 = item.OwnerTableView.ParentItem.GetDataKeyValue("ID").ToString();
               TextBox txtbox = (TextBox)item["temp"].FindControl("txt");
                txtbox.Text = customerId1;
           }
       }

    Thanks,
    Princy.
  7. illumination
    illumination avatar
    85 posts
    Member since:
    May 2008

    Posted 17 Jun 2011 Link to this post

    Perfect!!! Thank you so much, Princy.
  8. Jeffrey Sanford
    Jeffrey Sanford avatar
    5 posts
    Member since:
    Jul 2009

    Posted 14 Mar 2014 in reply to Princy Link to this post

    This actually just helped me.  Thanks!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017