Hi Kalina,
The scenario is that I have a RadcomboBox inside an insert template of a formview. The formview is bound to an SqlDataSource for inserting with two fields ItemId, ItemsSelected into a table.
The selectedvalue of the RadcomboBox is bound to the field ItemsSelected. The dropp down values for the RadCombobox are selected from another table using another SqlDataSource. More than one item can be selected separated with commas using checkboxes=true. This works fine.
The challenge is that when the insert button is click record, only the DataValueField of the first selected item is inserted into the table. How can I get it to insert the concatenated items (i.e all ticked items). The code is attached.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Test_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
<div>
<br />
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"
DefaultMode="Insert" Height="76px" Width="425px" DataKeyNames="ItemId">
<InsertItemTemplate>
ItemId:
<asp:TextBox ID="ItemIdTextBox" runat="server" Text='<%# Bind("ItemId") %>' />
<br />
ItemsSelected:
<telerik:RadComboBox ID="RadComboBox1" runat="server"
DataSourceID="SqlDataSource2" DataTextField="Source"
DataValueField="SourceId" CheckBoxes="True"
SelectedValue='<%# Bind("ItemsSelected") %>'>
</telerik:RadComboBox>
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CSFMonitoringConnectionString %>"
DeleteCommand="DELETE FROM [TestTable] WHERE [ItemId] = @ItemId"
InsertCommand="INSERT INTO [TestTable] ([ItemId], [ItemsSelected]) VALUES (@ItemId, @ItemsSelected)"
SelectCommand="SELECT [ItemId], [ItemsSelected] FROM [TestTable]"
UpdateCommand="UPDATE [TestTable] SET [ItemsSelected] = @ItemsSelected WHERE [ItemId] = @ItemId">
<DeleteParameters>
<asp:Parameter Name="ItemId" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ItemsSelected" Type="String" />
<asp:Parameter Name="ItemId" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="ItemId" Type="Int32" />
<asp:Parameter Name="ItemsSelected" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<br />
</div>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:CSFMonitoringConnectionString %>"
SelectCommand="SELECT [SourceId], [Source] FROM [tblInfoSource]">
</asp:SqlDataSource>
</form>
</body>
</html>