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

Find dynamically created Control

2 Answers 96 Views
PageView
This is a migrated thread and some comments may be shown as answers.
Chris Salas
Top achievements
Rank 1
Chris Salas asked on 16 Jan 2012, 09:59 PM
I have the following aspx code in a usercontrol:

<telerik:RadTabStrip ID="radTSCapabilities" runat="server" SelectedIndex="0" Skin="Default" MultiPageID="radMPCapabilities" />
    <telerik:RadMultiPage ID="radMPCapabilities" runat="server" SelectedIndex="0" />

I dynamically create the Tabs and PageViews from the code behind on load.  Inside the PageView is a RadTreeView.  See code below:
Telerik.Web.UI.RadPageView tmpPageView = new Telerik.Web.UI.RadPageView();
tmpPageView.ID = type.AbilityType.Name;
radMPCapabilities.PageViews.Add(tmpPageView);
 
//Add a Tab for the AbilityType
Telerik.Web.UI.RadTab tmpTab = new Telerik.Web.UI.RadTab(type.AbilityType.Name, type.AbilityType.ID.ToString());
tmpTab.PageViewID = tmpPageView.ID;
radTSCapabilities.Tabs.Add(tmpTab);
 
//Create and Load the Rad Tree
Telerik.Web.UI.RadTreeView radTree = new Telerik.Web.UI.RadTreeView();
radTree.Skin = "Default";
radTree.CheckBoxes = true;
radTree.TriStateCheckBoxes = true;
radTree.CheckChildNodes = true;
radTree.NodeDataBound += new Telerik.Web.UI.RadTreeViewEventHandler(radTree_NodeDataBound);
radTree.ID = type.AbilityType.ID.ToString() + type.AbilityType.Name.Replace(" ", "_");
radTree.DataTextField = "Name";
radTree.DataValueField = "ID";
radTree.DataFieldID = "ID";
radTree.DataFieldParentID = "ParentID";
 
//If there are multiple Ability Types in result set then go to the DB to get all Abilities for that type
if (distinctAbilityTypes.Count() != 1)
    radTree.DataSource = AbilityMgr.GetAbilitiesByAbilityTypeID(type.AbilityType.ID);
else
    radTree.DataSource = tmpAbilities;
 
//Bind the Tree
radTree.DataBind();
 
//Add a top border
Literal tmpLiteral = new Literal();
tmpLiteral.Text = "<div style='border-top:solid 1px #AAAAAA;'></div>";
 
//Add the Literal and Tree to the associated PageView
radMPCapabilities.FindControl(type.AbilityType.Name).Controls.Add(tmpLiteral);
radMPCapabilities.FindControl(type.AbilityType.Name).Controls.Add(radTree);

I am trying to get a reference to the dynamically created RadTreeView.  I have been unable to do so for some time now.  Please help.

Thank you.

2 Answers, 1 is accepted

Sort by
0
Chris Salas
Top achievements
Rank 1
answered on 16 Jan 2012, 11:33 PM
Sorry, I think this is in the wrong Forum, but maybe someone here can help me.
0
Stefan
Telerik team
answered on 17 Jan 2012, 11:56 AM
Hi Chris,

I am glad to see that you have found the right forum to address your question. Our colleagues there will help you out.

Regards,
Stefan
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Tags
PageView
Asked by
Chris Salas
Top achievements
Rank 1
Answers by
Chris Salas
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or