Select multiple values from ComboBox and write to database

4 posts, 0 answers
  1. davidp
    davidp avatar
    11 posts
    Member since:
    Jun 2012

    Posted 27 May 2010 Link to this post

    I am trying to use the autocomplete functionality on a ComboBox that is in a GridView Edit form.  I can select multiple objects but it is only writing the last item to the database.  I am using Update command that wwas created by my GridView's sqldatasource.
    Here is the code
    <telerik:RadComboBox ID="cboStaff" runat="server" Width="400px" Height="140px" MarkFirstMatch="true"  
         AllowCustomText="true"  AutoCompleteSeparator=";" 
         EmptyMessage="Select Staff assigned to case" DataSourceID="SqlDataSource5" DataTextField="res_name"
         DataValueField
    ="res_name" 
         AppendDataBoundItems="true" SelectedValue='<%# Bind( "staff" ) %>'
    </telerik:RadComboBox>



    <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
        ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" DeleteCommand="DELETE FROM [SurgeryCases_Main] WHERE [SurgeryCases_Main_id] = @original_SurgeryCases_Main_id" 
        InsertCommand="INSERT INTO [SurgeryCases_Main] ([ptcase_id], [displayname], [birth_datetime], [gender], [schedcase_start_datetime], [schedcase_stop_datetime], [actual_room_abbr], [actual_proname], [primpract_res_name], [crna], [staff], [sent_time], [pau_time], [or_time]) VALUES (@ptcase_id, @displayname, @birth_datetime, @gender, @schedcase_start_datetime, @schedcase_stop_datetime, @actual_room_abbr, @actual_proname, @primpract_res_name, @crna, @staff, @sent_time, @pau_time, @or_time)" 
        OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [SurgeryCases_Main]" 
        UpdateCommand="UPDATE [SurgeryCases_Main] SET [displayname] = @displayname, [birth_datetime] = @birth_datetime, [gender] = @gender, [actual_room_abbr] = @actual_room_abbr, [schedcase_start_datetime] = @schedcase_start_datetime, [primpract_res_name] = @primpract_res_name, [actual_proname] = @actual_proname, [crna] = @crna, [staff] = @staff WHERE [SurgeryCases_Main_id] = @original_SurgeryCases_Main_id"
        <DeleteParameters> 
            <asp:Parameter Name="original_SurgeryCases_Main_id" Type="Decimal" /> 
        </DeleteParameters> 
        <UpdateParameters> 
            <asp:Parameter Name="ptcase_id" Type="Decimal" /> 
            <asp:Parameter Name="displayname" Type="String" /> 
            <asp:Parameter Name="birth_datetime" Type="DateTime"  /> 
            <asp:Parameter Name="gender" Type="String" /> 
            <asp:Parameter Name="schedcase_start_datetime" Type="DateTime"  /> 
            <asp:Parameter Name="schedcase_stop_datetime" Type="DateTime" /> 
            <asp:Parameter Name="actual_room_abbr" Type="String" /> 
            <asp:Parameter Name="actual_proname" Type="String" /> 
            <asp:Parameter Name="primpract_res_name" Type="String" /> 
            <asp:Parameter Name="crna" Type="String" /> 
            <asp:Parameter Name="staff" Type="String" /> 
            <asp:Parameter Name="sent_time" Type="DateTime"  /> 
            <asp:Parameter Name="pau_time" Type="DateTime"  /> 
            <asp:Parameter Name="or_time" Type="DateTime"  /> 
            <asp:Parameter Name="original_SurgeryCases_Main_id" Type="Decimal" /> 
        </UpdateParameters> 
        <InsertParameters> 
            <asp:Parameter Name="ptcase_id" Type="Decimal" /> 
            <asp:Parameter Name="displayname" Type="String" /> 
            <asp:Parameter Name="birth_datetime" Type="DateTime"  /> 
            <asp:Parameter Name="gender" Type="String" /> 
            <asp:Parameter Name="schedcase_start_datetime" Type="DateTime"  /> 
            <asp:Parameter Name="schedcase_stop_datetime" Type="DateTime" /> 
            <asp:Parameter Name="actual_room_abbr" Type="String" /> 
            <asp:Parameter Name="actual_proname" Type="String" /> 
            <asp:Parameter Name="primpract_res_name" Type="String" /> 
            <asp:Parameter Name="crna" Type="String" /> 
            <asp:Parameter Name="staff" Type="String" /> 
            <asp:Parameter Name="sent_time" Type="DateTime"  /> 
            <asp:Parameter Name="pau_time" Type="DateTime"  /> 
            <asp:Parameter Name="or_time" Type="DateTime"  /> 
        </InsertParameters> 
    </asp:SqlDataSource> 

  2. davidp
    davidp avatar
    11 posts
    Member since:
    Jun 2012

    Posted 01 Jun 2010 Link to this post

    Any Ideas?
  3. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 04 Jun 2010 Link to this post

    Hi davidp,

    I am afraid that setting multiple values to RadComboBox control while implementing Autocomplete feature is not supported out of the box.

    However you can try to add a hidden field to your page and at OnClientSelectedIndexChanged event of the RadComboBox to collect the values of the selected items in this field. Than on server-side you can use the values to update your database.

    All the best,
    Kalina
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  4. AJ
    AJ avatar
    2 posts
    Member since:
    Apr 2011

    Posted 07 Jun 2013 Link to this post

    Can you provide a code sample of how to do that?
Back to Top