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

Insert Blank Line for Top Line In Combo Box

1 Answer 403 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 26 Mar 2010, 11:43 PM
I am populating the combo box from a column in the database.
Rather than having it load with the first item in the database,
I would like to have it load empty so the user does not have to delete any text when they first start typing.
Here are some of the things that I have tried, but did not work....

//this works with a regular drop down list, but not combo box.

//this.RadComboBox1.Items[0].Selected = false;

 

//this.RadComboBox1.SelectedValue = "";

 

 

//this.RadComboBox1.Item.Insert(0, new ListItem("--", ""));

 

 

//this.RadComboBox1.SelectedIndex = 0;

 

 


//this did not work
this
.RadComboBox1.Items[0].Selected = false;

 

 

this.RadComboBox1.SelectedValue = "";

How can I get it box to load blank or insert blank line?

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 29 Mar 2010, 08:24 AM

Hello Lori,

Try adding the RadComboBoxItem in DataBound event to show as default item when page loads.

C#:

 
    protected void RadComboBox2_DataBound(object sender, EventArgs e)  
    {  
        RadComboBox combo = (RadComboBox)sender;  
        combo.Items.Insert(0, new RadComboBoxItem(" --  """));  
        combo.Items[0].Selected = true;  
    } 

-Shinu.

Tags
ComboBox
Asked by
L
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or