Question

I have two RadListBoxes, i.e radListBoxSource and RadListBoxDestination.

Here I am binding radListBoxSource items with DataSource and transfer to RadListBoxDestination.

Now I want to add some text from TextBox to RadListBoxDestination which data is not in radListBoxSource.

For this I added TextBox and Button.
Please tell me how to bind TextBox data and radListBoxSource data to RadListBoxDestination.

.aspx:

<telerik:RadListBox runat="server" ID="radListBoxSource" Height="350px" Width="250px"
                    EnableDragAndDrop="true" TransferMode="Move" SelectionMode="Multiple" AllowTransfer="true"
                    TransferToID="RadListBoxDestination" AutoPostBackOnTransfer="true" DataSortField="CandidateColumn"
                    DataKeyField="ColumnID" AllowReorder="true">
    <EmptyMessageTemplate>
        No columns exist
    </EmptyMessageTemplate>
    <HeaderTemplate>
        <table width="100%">
            <tr>
                <td style="font-weight: bold; text-align: left;">
                    Candidate Columns
                </td>
            </tr>
        </table>
    </HeaderTemplate>
    <ItemTemplate>
        <div style="width: 100%;">
            <%# Eval("CandidateColumn") %>
        </div>
    </ItemTemplate>
</telerik:RadListBox>
<telerik:RadListBox ID="RadListBoxDestination" Height="350px" Width="250px" runat="server"
                    SelectionMode="Multiple" EnableDragAndDrop="true" AllowReorder="true">
    <EmptyMessageTemplate>
        No columns exist
    </EmptyMessageTemplate>
    <HeaderTemplate>
        <table width="100%">
            <tr>
                <td style="font-weight: bold; text-align: left;">
                    Candidate Columns
                </td>
            </tr>
        </table>
    </HeaderTemplate>
    <ItemTemplate>
        <div style="width: 100%;">
            <%# Eval("CandidateColumn") %>
        </div>
    </ItemTemplate>
</telerik:RadListBox>

<table>
    <tr>
        <td>
            <asp:Label ID="lblText" runat="server" Text="Enter Custom Field Name" Font-Bold="true"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="txtFieldName" runat="server" Width="175px"></asp:TextBox>
        </td>
        <td>
            <asp:Button ID="btnAdd" CssClass="form_btn_txt" runat="server" Text="Add" OnClick="btnAdd_Click" />
        </td>
    </tr>
</table>

.cs:

protected void btnAdd_Click(object sender, EventArgs e)
{
    RadListBoxItem test1 = new RadListBoxItem("item 1");
    test1.Text = txtFieldName.Text.Trim();
    RadListBoxDestination.Items.Insert(test1.Clone());              
}

And I am binding radListBoxSource as follows:

private void FillComboData()
{
    BizCandidate bizCandidates = new BizCandidate();
    DataSet dsCandidates = new DataSet();

    try
    {
        dsCandidates = bizCandidates.GetCandidateColumns();

        if (dsCandidates != null && dsCandidates.Tables.Count > 0)
        {
            if (dsCandidates.Tables[0].Rows.Count > 0)
            {
                radListBoxSource.DataSource = dsCandidates.Tables[0];
                radListBoxSource.DataValueField = "ColumnID";
                radListBoxSource.DataTextField = "CandidateColumn";
                radListBoxSource.DataBind();
            }
        }
    }
    catch { }
}
Was it helpful?

Solution

Remove the itemTemplate from the RadListBoxDestination, as you are not using a data source for this list box:

<telerik:RadListBox ID="RadListBoxDestination" Height="350px" Width="250px" runat="server"
                    SelectionMode="Multiple" EnableDragAndDrop="true" AllowReorder="true">
    <EmptyMessageTemplate>
        No columns exist
    </EmptyMessageTemplate>
    <HeaderTemplate>
        <table width="100%">
            <tr>
                <td style="font-weight: bold; text-align: left;">
                    Candidate Columns
                </td>
            </tr>
        </table>
    </HeaderTemplate>
</telerik:RadListBox>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top