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

RadComboBoxItem Add not working

1 Answer 66 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Josh
Top achievements
Rank 1
Josh asked on 20 May 2009, 11:12 PM
I am tweaking the MyCustomFilteringColumn to filter a RadGrid.  The data is populating the
comboboxes just fine, however, I cannot seem to add an "All" item at the top of each
combobox.  Below is the code.  Thanks for any help provided.
public class MyCustomFilteringColumnCS : GridBoundColumn   
{  
//RadGrid will call this method when it initializes the controls inside the filtering item cells   
   
protected override void SetupFilterControls(TableCell cell)   
{  
RadGrid RadGrid2 = (RadGrid)cell.Page.FindControl("RadGrid1");   
base.SetupFilterControls(cell);   
cell.Controls.RemoveAt(0);  
RadComboBox combo = new RadComboBox();   
combo.ID = ("ComboBox_" + this.UniqueName);   
combo.ShowToggleImage = false;   
combo.Skin = "Office2007";   
combo.AutoPostBack = true;   
combo.Items.Add(new RadComboBoxItem("All""%"));   
combo.DataSource = RadGrid2.DataSource;  
combo.DataTextField = this.UniqueName;   
combo.DataValueField = this.UniqueName;   
combo.Items.Insert(0, new RadComboBoxItem("All","%"));   
combo.DataBind();  
combo.SelectedIndexChanged += this.list_SelectedIndexChanged;   
cell.Controls.AddAt(0, combo);  
cell.Controls.RemoveAt(1);  
}  
 
 

 

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 21 May 2009, 07:10 AM
Hello Josh,

Please try calling the DataBind method before inserting the 'All' Item.

combo.Items.Insert(0, new RadComboBoxItem("All","%"));    
combo.DataBind(); 
->
combo.DataBind(); 
combo.Items.Insert(0, new RadComboBoxItem("All","%")); 


All the best,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Tags
ComboBox
Asked by
Josh
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or