Jump to content
Software FX Community

Referencing Nested Controls


Recommended Posts

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.?



Link to comment
Share on other sites


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?

Link to comment
Share on other sites

so close...i used the following sample - it still returns null:


 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?  


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...