【问题标题】:Telerik radlistbox datakey does not transferTelerik radlistbox 数据密钥不传输
【发布时间】:2015-04-07 16:05:10
【问题描述】:

我有两个 Telerik radListBoxes(源和目标)。两者都是数据绑定的,它们的 DataKeyField 和 DataTextField 值已设置。目标列表框可能包含来自先前会话的一些值。

当我使用内置按钮将项目从源列表框传输到目标列表框时,我可以看到值(文本)被传输过来,但该项目的数据键为空。

我是这些控件的新手,除此之外一切都运行良好。

<telerik:RadListBox runat="server" ID="rlAvailableTitles" Height="200px" Width="300px" ButtonSettings-AreaWidth="35px" 
    AllowTransfer="true" TransferToID="rlTitles" SelectionMode="Multiple" AppendDataBoundItems="true"
    AllowTransferOnDoubleClick="true" DataKeyField="TitleID" DataTextField="TitleName" CssClass="text-align: left;" AutoPostBackOnTransfer="true">
</telerik:RadListBox>
<telerik:RadListBox runat="server" ID="rlTitles" Height="200px" Width="300px" ButtonSettings-AreaWidth="35px"
    AllowTransfer="true" TransferToID="rlAvailableTitles" SelectionMode="Multiple" AppendDataBoundItems="true"
    AllowTransferOnDoubleClick="true" DataKeyField="TitleID" DataTextField="TitleName">
</telerik:RadListBox>

在他们点击“保存”后:

foreach (RadListBoxItem item in rlTitles.Items)
{
    string myTitleID = item.DataKey;
    // etc...
} 

我缺少什么来获取与源列表框中的项目一起存储的数据键?

【问题讨论】:

  • 您的问题是什么?更具体。
  • 很高兴看到您使用的代码来帮助其他人了解您的不足...

标签: c# asp.net telerik radlistbox


【解决方案1】:

DataKey 没有设置器。

改用 DataValueField。

【讨论】:

    【解决方案2】:

    我找到了解决这个特定问题的方法。我在 aspx 文件的源 radListBox 中添加了DataValueField="TitleID"。然后在我后面的代码中,我在目标 radListBox 中寻找的值在item.Value 中可用。回想起来似乎很简单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-04
      • 2019-12-22
      • 1970-01-01
      相关资源
      最近更新 更多