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

problem to show ---- Select ---

4 Answers 113 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jun Ting
Top achievements
Rank 1
Jun Ting asked on 16 Oct 2008, 05:21 PM
i want the combobox show the "---Select ---" when page load, but don't want  to show it in the drop down list.

Below is the code that i used, it causes the "---Select---" show on the drop down list. How to remove the "---Select ---" in drop down list, but keep remain it when page load?



 <radc:radcombobox runat="server" id="cbSpecialty" markfirstmatch="True" enabletheming="True"
                                            skin="healthcare" height="90" width="160">
            </radc:radcombobox>


 Dim drow As DataRow
            Dim cnt As Integer = 1
            dt = mClas.GetDataTable("SELECT     specialtyID, spec_name FROM specialty where spec_status=1")

            cbSpecialty.Items.Add(New Telerik.WebControls.RadComboBoxItem("--- Select --- ", ""))
         
            For Each drow In dt.Rows
                cbSpecialty.Items.Add(New Telerik.WebControls.RadComboBoxItem(drow("spec_name"), drow("specialtyID")))
            Next

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Oct 2008, 06:34 AM
Hi,

Try adding the " --Select--" text in the Page Load event as shown below.

CS:
 protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!IsPostBack) 
            RadComboBox1.Items[0].Text = "--Select--"
        else 
            RadComboBox1.Items.Remove(0); 
    } 


Thanks
Shinu.
0
Veselin Vasilev
Telerik team
answered on 17 Oct 2008, 08:59 AM
Hello Jun,

You can set the Text property of RadComboBox to "Select". Note that you will need to set the AllowCustomText property to True in addition.

Sincerely yours,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jun Ting
Top achievements
Rank 1
answered on 21 Oct 2008, 03:41 AM
 Hi Veselin,

I have used the Text Property of  RadComboBox to "Select".
It solved my problem.

Now i have another problem. In my form , i have a search function. The search function will fire when the textbox is not empty or when the items in the combobox is selected.

But i found that when i only fill the textbox & not selected the items of combobox. I always get the result for the "first" item of combobox.

How can i set the combobox? if no selected item, then show all the field inside the combobox ( not only the first item in combobox). Thanks.


 
0
Veselin Vasilev
Telerik team
answered on 23 Oct 2008, 03:11 PM
Hi Jun Ting,

I am afraid I could not understand your logic. Can you please elaborate a bit more?

Thanks

All the best,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Jun Ting
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Veselin Vasilev
Telerik team
Jun Ting
Top achievements
Rank 1
Share this question
or