Saving selected items in MultiSelect (Template Column in a Grid) to SQLDataSource

1 Answer 407 Views
Grid MultiSelect
Angela
Top achievements
Rank 1
Iron
Angela asked on 15 Feb 2022, 03:19 PM

I have a Grid with a template column with a MultiSelect as the EditItemTemplate. The MultiSelect displays fine with all of the available values, but I can't figure out how to save the selected items to the database.

When I use a ComboBox, I used SelectedValue='<%# Bind("Team_ADS_Person_IDs") %>' to bind and the selected value is saved in the Team_ADS_Person_ID field correctly, but I'm not sure what to use for the MultiSelect.

<MasterTableView DataKeyNames="Record_ID" EditMode="InPlace" DataSourceID="sql" AutoGenerateColumns="false" AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true">
    <Columns>
        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderStyle-Width="110px"></telerik:GridEditCommandColumn>
        <telerik:GridTemplateColumn HeaderText="Team" SortExpression="Team_ADS_Person_IDs" HeaderStyle-Width="275px">
            <ItemTemplate>
                <%# Eval("Team_ADS_Person_IDs")%>
            </ItemTemplate>
            <EditItemTemplate>
                <telerik:RadMultiSelect ID="selTeam" runat="server" DataSourceID="sqlEmployee" DataTextField="Display_Name" DataValueField="ADS_Person_ID" Filter="Contains" Width="100%" AutoClose="False"></telerik:RadMultiSelect>
            </EditItemTemplate>
        </telerik:GridTemplateColumn>
        <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ConfirmText="Are you sure you want to delete this record?" HeaderStyle-Width="50px" UniqueName="DeleteCommandColumn">
        </telerik:GridButtonColumn>
    </Columns>
</MasterTableView>
</telerik:RadGrid>


<asp:SqlDataSource ID="sql" runat="server" ConnectionString="<%$ ConnectionStrings:csCHPServiceDesk %>" SelectCommand="Release.usp_Product" SelectCommandType="StoredProcedure" InsertCommand="Release.usp_Product" InsertCommandType="StoredProcedure" UpdateCommand="Release.usp_Product" UpdateCommandType="StoredProcedure" DeleteCommand="Release.usp_Product" DeleteCommandType="StoredProcedure">
    <SelectParameters>
        <asp:Parameter Name="Action" DefaultValue="Select" Type="String" />
    </SelectParameters>
    <InsertParameters>
        <asp:Parameter Name="Action" DefaultValue="Insert" Type="String" />
        <asp:Parameter Name="Team_ADS_Person_IDs" Type="String" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="Action" DefaultValue="Update" Type="String" />
        <asp:Parameter Name="Record_ID" Type="Int32" />
        <asp:Parameter Name="Team_ADS_Person_IDs" Type="String" />
    </UpdateParameters>
    <DeleteParameters>
        <asp:Parameter Name="Action" DefaultValue="Delete" Type="String" />
        <asp:Parameter Name="Record_ID" Type="Int32" />
    </DeleteParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="sqlEmployee" runat="server" ConnectionString="<%$ ConnectionStrings:csCHPServiceDesk %>" SelectCommand="usp_Lookup" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:Parameter Name="Action" DefaultValue="Select Employee" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

1 Answer, 1 is accepted

Sort by
0
Accepted
Attila Antal
Telerik team
answered on 18 Feb 2022, 09:58 AM

Hi Angela,

Thank you for the question.

As this is a highly demanded scenario, we have created a Knowledge Base article to address it.

Please visit the Edit Grid columns with MultiSelect article at https://docs.telerik.com/devtools/aspnet-ajax/knowledge-base/grid-edit-columns-with-multiselect.

I hope this will prove helpful.

Regards,
Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Angela
Top achievements
Rank 1
Iron
commented on 28 Feb 2022, 08:40 PM

Thank you so much! I appreciate it.
Tags
Grid MultiSelect
Asked by
Angela
Top achievements
Rank 1
Iron
Answers by
Attila Antal
Telerik team
Share this question
or