我有两个RadListBoxes
,即radListBoxSource
和RadListBoxDestination
。
在这里,我将radListBoxSource
项目绑定DataSource
并转移到RadListBoxDestination
.
现在我想添加一些数据不在的TextBox
文本。RadListBoxDestination
radListBoxSource
为此,我添加了TextBox
和Button
。
请告诉我如何将TextBox
数据和radListBoxSource
数据绑定到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());
}
我正在绑定 radListBoxSource 如下:
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 { }
}