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

[Solved] Find Control Is Null

1 Answer 183 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Thannapan Boonpannaruk
Top achievements
Rank 1
Thannapan Boonpannaruk asked on 19 Dec 2009, 08:57 PM
Hi there,

I try to reference my radcombobox on code behind but it dosen't work and told me that it's null !!

Here my code,

Binding !!!

 

RadComboBox cbF1 = new RadComboBox();

 

cbF1.ID =

"cbF1";

 

 

cbF1.Style[

"Position"] = "Absolute"; cbF1.Style["Top"] = "180px"; cbF1.Style["Left"] = "180px"; cbF1.Width = 120;

 

 

cbF1.Skin =

"Simple";

 

 

 

cbF1.DataSource = ds.Tables[0]; cbF1.DataTextField =

"FTFIELDNAME"; cbF1.DataValueField = "FTTABLENAME"; cbF1.DataBind();

It's shown Correctly !! It's work !!
But when I wanna shake it out to get the value ...

 

 

 

RadComboBox 

 

rcbF = Panel2.FindControl("cbF1") as RadComboBox;

Show me !!
"rcbF = null"

Anyone please help me !!

Thannapan. 

 

 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Dec 2009, 07:13 AM
Hello Tannapan,

I tried the following code and it is working fine on my end. Here is the code that I tried.

CS:
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        RadComboBox cbF1 = new RadComboBox(); 
        cbF1.ID ="cbF1"
        Panel2.Controls.Add(cbF1); 
    } 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadComboBox rcbF = Panel2.FindControl("cbF1"as RadComboBox; 
    } 
Could you provide some more information about the in which event you are trying your code, if this doesn't help?

-Shinu.
Tags
ComboBox
Asked by
Thannapan Boonpannaruk
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or