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

How to set default vale for multi select radcombobox

7 Answers 763 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Maddela
Top achievements
Rank 1
Maddela asked on 17 Nov 2011, 10:14 AM
Hi

I am using the following code for multi select drop down list. I want to set default value when page gets loads.

<telerik:RadComboBox runat="server" ID="RadComboBoxProvider" AllowCustomText="true"
                            Text="Select" >
                            <ItemTemplate>
                                <asp:CheckBox runat="server" ID="cbProvider" AutoPostBack="true" Text='<%#Eval("First_Name")%>' />
                            </ItemTemplate>
                        </telerik:RadComboBox>

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Nov 2011, 10:24 AM
Hello,

You can set EmptyMessage property of RadComboBox.

Thanks,
Princy.
0
Maddela
Top achievements
Rank 1
answered on 17 Nov 2011, 10:29 AM

I not able to follow you properly, do you have any sample code. If you don't mind
0
Princy
Top achievements
Rank 2
answered on 17 Nov 2011, 10:54 AM
Hello,

You can try the following sample code.
ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1" DataTextField="FirstName" DataValueField="FirstName" EmptyMessage="Select" Width="300px" AutoPostBack="true">
</telerik:RadComboBox>

Thanks,
Princy.
0
Maddela
Top achievements
Rank 1
answered on 17 Nov 2011, 11:25 AM

       No not like that, i am using multi select drop down list, and filling that from data base values, if i give radcombobox.selectedvalue=2 the value should be checked in that combobox. please look into my attached scree shot for clear understand.
0
Kalina
Telerik team
answered on 22 Nov 2011, 08:36 AM
Hello Maddela,

Can you paste here the full RadComboBox markup that you use?

Regards,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Maddela
Top achievements
Rank 1
answered on 22 Nov 2011, 12:22 PM
<telerik:RadComboBox runat="server" ID="RadComboBoxProvider" AllowCustomText="true"
                            Text="Select" >
                            <ItemTemplate>
                                <asp:CheckBox runat="server" ID="cbProvider" AutoPostBack="true" Text='<%#Eval("First_Name")%>' />
                            </ItemTemplate>
                        </telerik:RadComboBox>
0
Kalina
Telerik team
answered on 24 Nov 2011, 11:08 PM
Hi Maddela,

Let me suggest you use the RadComboBox CheckBoxes feature.
Please take a look at the “ComboBox / CheckBoxes“ online demo and the “CheckBox Support” help article.

If you want to display the texts of the RadComboBox items that have been already checked – you can easily make this by handling the OnItemDataBound event:
<telerik:RadComboBox ID="RadComboBox1" runat="server"
    OnItemDataBound="OnItemDataBound" AutoPostBack="true"
    OnItemChecked="OnItemChecked" CheckBoxes="true">
</telerik:RadComboBox>
protected void OnItemDataBound(object sender, RadComboBoxItemEventArgs e)
{
    RadComboBox combo = (RadComboBox)sender;
    DataRowView dr = (DataRowView)e.Item.DataItem;
 
    if (Boolean.Parse(dr["Checked"].ToString()))
    {
        e.Item.Checked = true;
    }
 
}

Then you can update the database within the OnItemChecked event handler.
I am attaching here a basic example - it is quite simple but I believe that it will help you get started your implementation.

Greetings,
Kalina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ComboBox
Asked by
Maddela
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Maddela
Top achievements
Rank 1
Kalina
Telerik team
Share this question
or