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

Accessing controls inside RadPageView, RadMultiPage

1 Answer 312 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 07 Dec 2011, 09:17 PM
I'm following the telerik demo Grid Heirachy with Templates. On the sub grids I want to give the user "Add new Record" ability. I have that partially working except that on each new row three of my columns need to be "related comboboxes", as demostrated in this telerik example. In my implementation, my three related combo boxes are a list of clients, sub list of projects and sub list of project requirements.

The problem I run into is that the webpage can't find the comboboxes in my javascript code when the page first loads, it throws an error.

"The name 'RadComboBox_Project' does not exist in the current context"

Line 395:            function LoadProjects(sender, eventArgs) {
Line 396:                 var projectsCombo = $find("<%= RadComboBox_Project.ClientID %>");
Line 397:                var requirementsCombo = $find("<%= RadComboBox_Requirement.ClientID %>");

I think the reason this might be happening is because the RadGrid2 is located inside of a <telerik:RadPageView> control or within other nested controls. The aspx page when in Design mode doesn't show the RadGrid2 on the designer surface at all, it's somehow hidden. Probably because RadGrid2 is a subgrid of RadGrid1 and also that RadGrid2 is nested inside of a RadPageView, that being nested inside of a RadMultiPage and that being nested inside of an asp:Panel. (I'm using the exact code example from Grid Heirachy with Templates)

Another issue with the nested RadGrid2 is that it doesn't show up at all in the Properties window listbox in Visual Studio. None of the nested RadGrids on each RadPageView are visible. There are RadGrids on each of the Tabs of the RadTabStrip. All of these RadGrids are not visible.

In the c# code behind class, you also can't reference them. Code like this doesn't compile::

int x = RadGrid2.MasterTableView.Columns.Count;

RadComboBox_Project.DataTextField = "Name";
// this is a combobox within RadGrid2

Both of those two controls show the red squiggly lines, if you hover over them the VS tooltip tells me the same error: 
"The name 'RadGrid2' does not exist in the current context".
"The name 'RadComboBox_Project' does not exist in the current context".

It seems like there is one central error causing all of these nested controls to be hidden from the compiler. Any idea how to make them available for use so I can reference them in javascript and in c# code behind?

Thank you.

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 12 Dec 2011, 01:29 PM
Hello David,

Whether the grid is located in a pageview or not doesn't affect the way you access controls since the pagevies is just a container. From what you have explained as scenario, your comboboxes are located in the insert or edit form of your grid. If this is the case you are not able to access them upon initial load since they do not exist until you try to add a new record. Please refer to the following code library, on how to use related comboboxes in Edit/Insert form of the RadGrid.

Greetings,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or