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

[Solved] Manually inserting CheckBox Item not working

1 Answer 218 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michael Love
Top achievements
Rank 1
Michael Love asked on 10 Feb 2010, 07:57 PM

Hi there.

I am trying to manually insert an item into the dataset for a RadComboBox as shown below:

cbProviders.Items.Insert(0,

new RadComboBoxItem(CurrentUser.CompanyName, CurrentUser.OperatorId.ToString() + "-" + EvaluationOwnerType.Operator.GetHashCode().ToString()));

My problem is that the item is really an ASP:CheckBox inside of an ItemTemplate as shown:

 

<ItemTemplate

 

 

 

 

 

 

<asp:CheckBox runat="server" ID="CheckBox" onclick="checkboxClick();" Text='<%# DataBinder.Eval(Container, "Text") %>'/> 

 

 

 

 

 

 

</ItemTemplate>

I am not sure how to accomplish this. Currently, the checkboix shows, but not the associated text. Any help would be appreciated.

Thanks, Mike

 

 

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Feb 2010, 05:58 AM
Hello Michael,

From your code, I can understand that you are setting Text property for the CheckBox placed in ItemTemplate. So when inserting new radcombobox item, set the Text for the checkbox also as shown below.

C#:
 
    protected void Button1_Click(object sender, EventArgs e) 
    { 
        RadComboBox1.Items.Insert(0, new RadComboBoxItem()); 
        (RadComboBox1.Items[0].FindControl("CheckBox"as CheckBox).Text = "Your text"
    } 

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