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

[Solved] List all radcontrols

2 Answers 200 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
BOS
Top achievements
Rank 1
BOS asked on 15 Mar 2010, 10:01 AM
I have previosly used Page.Controls in projects to loop thru all server controls this:

    foreach (Control ctrl in Page.Controls)
    {
        findCtrl(ctrl);
    } 

   
public void findCtrl(Control ctrlTry)
    {
        if (ctrlTry.HasControls()) // if the control contrains other controls
        {
           
            if (ctrlTry.ID != null && ctrlTry.ID != "") // control has a ID-name
            {
                Response.Write(ctrlTry.ID + "<BR>");
            }

 

            foreach (Control lastCtrl in ctrlTry.Controls)
            {
                findCtrl(lastCtrl);
            }
        }
        else
        {
            if (ctrlTry.ID != null && ctrlTry.ID != "")
            {
                Response.Write(ctrlTry.ID + "<BR>");
            }
        }
    }

I've placed some radtextboxes in a Formview and used a table in the EditItemTemplate for design-reasons.
But then I can't use this approach.

 

<asp:FormView ID="FormView1" runat="server"
                  DataSourceID="sdsMeHaulier"
                  DataKeyNames="HaulierID"
                  DefaultMode="Edit" 
                  onitemupdated="FormView1_ItemUpdated" >       
        <EditItemTemplate>
            <table id="tblHaulier">
                <tr>
                    <td valign="top">
                        <telerik:RadTextBox ID="tbHaulierName" runat="server"
                                            Label="HaulierName"
                                            Text='<%# Bind("HaulierName") %>'
                                            Enabled="true"
                                            EnableTheming="True"
                                            ReadOnly="false" >
                        </telerik:RadTextBox>
                        <br />
                       
                        <telerik:RadTextBox ID="tbDepName" runat="server"
                                            Label="DepName"
                                            Text='<%# Bind("DepName") %>'
                                            Enabled="true"
                                            EnableTheming="True"
                                            ReadOnly="false"

and so on.
None of the radtextboxes appear in the list of controls.

Any ideas?  

 

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Greg Le Moine
Top achievements
Rank 1
answered on 15 Mar 2010, 11:25 AM
I customize all my radgrid controls in the each page load with a function like you. But I have some problem with a scheduler or a formView

In fact, you must call your function in the  YourFrmVvw_DataBound event.
(the same thing for a scheduler, you must call your function in the YourSheduler_FormCreated event)
0
BOS
Top achievements
Rank 1
answered on 15 Mar 2010, 11:34 AM
Hi Gregory

Thanks a lot, that solved my problem :-)
Tags
General Discussions
Asked by
BOS
Top achievements
Rank 1
Answers by
Greg Le Moine
Top achievements
Rank 1
BOS
Top achievements
Rank 1
Share this question
or