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

[Solved] FindControl within RadGrid

2 Answers 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Han
Top achievements
Rank 1
Han asked on 23 Apr 2009, 03:31 PM
Hi,

I have a CheckBoxList inside FormTemplate (MasterTableViewEditForm) of a RadGrid.
I cannot find it using something like

RadGrid1.FindControl("controlID");

Any help is greatly appreciated.

han

2 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Apr 2009, 04:37 PM
Hello Zhe,

Please examine the following links:
Referencing controls in grid row/edit form
How to find controls from EditFormSettings.FormTemplate

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Matt Johnston
Top achievements
Rank 1
answered on 05 Oct 2009, 10:23 PM
Here is what I'm using to get the selected values from a CheckBoxList. You can shorten it by setting
editedItem.FindControl("applications"as CheckBoxList 
to an object and reuse it instead of repeating the statement like I did.

        //Applications variable 
        string applications = ""
 
        // loop trough checkboxes 
        for (int i = 0; i < (editedItem.FindControl("applications"as CheckBoxList).Items.Count; i++) 
        { 
            if ((editedItem.FindControl("applications"as CheckBoxList).Items[i].Selected) 
            { 
                // Build the list the selected values 
                applications += (editedItem.FindControl("applications"as CheckBoxList).Items[i].Value + ","
               
            } 
        } 
        applications = applications.TrimEnd(','); // remove the trailing comma from the string 

Tags
Grid
Asked by
Han
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Matt Johnston
Top achievements
Rank 1
Share this question
or