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

Adding data afetr populating

3 Answers 27 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
anshul kumar
Top achievements
Rank 1
anshul kumar asked on 09 Apr 2010, 08:17 AM

I have populated my rad combo box from database but i want to add a item named as "Select" as default to be shown initially after being populated.

Like if data from database if 1,2,3,4 then data should be displayed as select,1,2,3,4.

anyone help please.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 09 Apr 2010, 09:37 AM
Hello Anshul,

You can add an item with Text as "Select" to the RadComboBox after it is populated from database by using the following code.

C#:
 
    protected void RadComboBox1_DataBound(object sender, EventArgs e) 
    { 
        RadComboBoxItem item = new RadComboBoxItem("Select"); 
        RadComboBox1.Items.Insert(0, item); 
    } 

Regards,
Shinu.
0
anshul kumar
Top achievements
Rank 1
answered on 09 Apr 2010, 03:04 PM
Error 3 The type or namespace name 'RadComboBoxItem' could not be found (are you missing a using directive or an assembly reference?) D:\Anshul\College site\Student\books.aspx.cs 33 13 D:\Anshul\College site\

Error 4 The type or namespace name 'RadComboBoxItem' could not be found (are you missing a using directive or an assembly reference?) D:\Anshul\College site\Student\books.aspx.cs 33 40 D:\Anshul\College site\

these errors are shown after using your statement

0
k f
Top achievements
Rank 1
answered on 09 Apr 2010, 06:09 PM
anshul,

Have you checked out the documentation.  There is an example of how to do this.

http://www.telerik.com/help/aspnet-ajax/combo-insert-default-item-when-databinding.html

Also, I've been working in WPF for a while now but does the Ajax RadCombo have an EmptyText property?

I use that and don't have to bother with adding a default Item.  If nothing is set to SelectedItem when you populate, the text you use for EmptyText will show in the combo.

Tags
ComboBox
Asked by
anshul kumar
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
anshul kumar
Top achievements
Rank 1
k f
Top achievements
Rank 1
Share this question
or