Multiple Selection of radcombobox

2 posts, 0 answers
  1. Edd
    Edd avatar
    37 posts
    Member since:
    Jan 2013

    Posted 14 Nov 2013 Link to this post

    Good day,
    please am using a radcombobox that allows for multiple selection.
    My problem is how can i insert the selected items into a database one by one.
    Can someone please help me
    thank you
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Nov 2013 Link to this post

    Hi Edd,

    Please have a look into the code snippet to insert the Selected Item of RadComboBox into DataBase on RadButton OnClick event.

    <telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true">
            <telerik:RadComboBoxItem Text="Australia" runat="server" />
            <telerik:RadComboBoxItem Text="Austria" runat="server" />
            <telerik:RadComboBoxItem Text="Bahrain" runat="server" />
            <telerik:RadComboBoxItem Text="Bangladesh" runat="server" />
            <telerik:RadComboBoxItem Text="Belgium" runat="server" />
            <telerik:RadComboBoxItem Text="Bhutan" runat="server" />
    <telerik:RadButton ID="RadButton1" runat="server" Text="Get Selected Item" OnClick="RadButton1_Click">

    protected void RadButton1_Click(object sender, EventArgs e)
        foreach (RadComboBoxItem item in RadComboBox1.Items)
            if (item.Checked == true)
                String connstring = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString;
                SqlConnection conn = new SqlConnection(connstring);
                SqlCommand cmd = new SqlCommand("insert into CountryTable (CountryName) values('" + item.Text + "')", conn);

Back to Top