RadComboBox from code-behind not declared?

2 posts, 0 answers
  1. Fit2Page
    Fit2Page avatar
    345 posts
    Member since:
    Feb 2007

    Posted 15 Feb 2010 Link to this post

    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



  2. Fit2Page
    Fit2Page avatar
    345 posts
    Member since:
    Feb 2007

    Posted 16 Feb 2010 Link to this post

    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


  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top