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

RadComboBox from code-behind not declared?

1 Answer 137 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Fit2Page asked on 15 Feb 2010, 11:13 AM
Hi,

I have the following problem. I create RadComboBox in code-behind Page_init

Dim ddl As RadComboBox 
Dim sqlSource As SqlDataSource 
ddl = New RadComboBox 
sqlSource = New SqlDataSource 
 
sqlSource.ConnectionString = WebConfigurationManager.ConnectionStrings(TablePrefix).ConnectionString 
sqlSource.SelectCommand = " SELECT ValueText, " & UItaal & "text AS tekst FROM " & TablePrefix & "_" & ArrCategory & " " 
 
plh_Category.Controls.Add(ddl) 
 
ddl.DataSource = sqlSource 
ddl.ID = "ddl_BU" 
 
ddl.EmptyMessage = GetGlobalResourceObject("Insight", "Maak uw selectie") 
ddl.DataValueField = "ValueText" 
ddl.DataTextField = "tekst" 
ddl.DataBind() 
The ComboBox is created OK but I cannot find it with

Dim ddl As RadComboBox = Page.FindControl("ddl_BU") 

It's keep telling me

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.





Why isn't the control added to the Controls collection?

Regards,
Marc



1 Answer, 1 is accepted

Sort by
0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 16 Feb 2010, 09:32 AM
OK this is working now, I did find the control with:

Dim ddl As RadComboBox = plh_Category.FindControl("ddl_BU")  
Thanks for yr time

Marc


Tags
ComboBox
Asked by
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or