mammal Posted June 2, 2008 Report Share Posted June 2, 2008 Hi, i posted the following over a week ago....: having used the designer to assemble parent-child, hierarchical gridstructure, how programmatically can i reference the nested grids? Forexample: ... grid1.FindControls("Grid2") ... Can you shine a light on this.? Thanks Quote Link to comment Share on other sites More sharing options...
StephenP Posted June 2, 2008 Report Share Posted June 2, 2008 Hi, Sorry about the lack of response. Referencing child grids is pretty easy. First, you need to reference the child grid's container. From there, finding the child grid is easy. If your child grid is in a side bar, it's super easy: grid1.SideBars[0].FindControl("grid2"); If your child grid is in the ItemDetails area, you first need to reference the item, then call its FindControlInTemplate method. grid1.Items[0].FindControlInTemplate("grid2") Does this answer your question? Quote Link to comment Share on other sites More sharing options...
mammal Posted June 3, 2008 Author Report Share Posted June 3, 2008 so close...i used the following sample - it still returns null: grid1.Items[0].FindControlInTemplate("grid2") the following mark-up shows how the grid is nested within the parent grid .... </DataFields> <ItemDetails> <ContentTemplate> <GridFX:Grid ID="Grid2" runat="server" DataParameterField="RegionID" OnSelectedItemsChanged="GridSelectedItemsChanged"> Any thoughts? Thanks Quote Link to comment Share on other sites More sharing options...
StephenP Posted June 3, 2008 Report Share Posted June 3, 2008 In order for the Grid2 to exist, the item needs to be expanded. However, the expansion happens after OnLoad. There is an event on grid called ItemDetailsExpansionChanged. Handle that event. Check to see if the item is expanded via e.Expanded. If that is true, the FindControlInTemplate should return the grid. You can also do e.DetailsCell.FindControl in the event handler. Try that. Let me know how it works out. Quote Link to comment Share on other sites More sharing options...
mammal Posted June 17, 2008 Author Report Share Posted June 17, 2008 works fine. thanks for your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.