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

FindControl inside FormView Template fails

1 Answer 217 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 28 Jul 2009, 12:07 AM
I have a project that I am in the process of replacing the drop down lists with comboboxes.

In this scenario, the drop down list will show / hide a panel (using an ajax CollapsiblePanelExtender) when a certain value is selected. This is working well (before the replacement of the ddl with the combo box).

I have added and databound the combobox, which shows the required data values.

However, when I attempt to find the combobox, the combobox is not found. The combobox is inside the insert item template of the form view and I am using master / child pages.

Here is my server side code:

 

protected void FormViewSkillDetails_DataBound(object sender, EventArgs e)

 {
    

if (FormViewSkillDetails.CurrentMode == FormViewMode.Insert)
    {
        FormViewSkillDetails.Focus();
//place the cursor on the 1st available field of the form view.
        
        
//DropDownList ddl = (DropDownList)FormViewSkillDetails.FindControl("DropDownListSkillTypeInsertDisplay"); 
        
RadComboBox ddl = (RadComboBox)FormViewSkillDetails.FindControl("RadComboBoxSkillTypeInsertDisplay");
        
Panel p = (Panel)FormViewSkillDetails.FindControl("PanelSkillOwnHeadingInsertItem");
        
RequiredFieldValidator rfv = (RequiredFieldValidator)FormViewSkillDetails.FindControl("RequiredFieldValidatorClientSideSkillOwnHeadingInsert");
        
CustomValidator cvss = (CustomValidator)FormViewSkillDetails.FindControl("CustomValidatorServerSideSkillOwnHeadingInsertItemBlank");
        ddl.Attributes.Add(
"onchange", "JavaScript:selectInputInsertChange('" + ddl.ClientID + "', '" + p.ClientID + "', '" + rfv.ClientID + "', '" + cvss.ClientID + "');");
    }
}

Any suggestions?

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Jul 2009, 07:42 AM
Hi Matt,

Can you confirm that you are trying to access the RadComboBox using its correct ID? It would be nice if you could send the entire aspx page.

Shinu
Tags
ComboBox
Asked by
Matt
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or