Listbox DataTextField with more than one field

4 posts, 0 answers
  1. Bob
    Bob avatar
    4 posts
    Member since:
    Apr 2014

    Posted 02 May 2014 Link to this post

    I would like the Text to contain the combination of the data source's id and name fields.  For example the control:

    <telerik:RadListBox runat="server" ID="lstAvailableRemarkCode" Width="500px"<br>                                       Height="300px" SelectionMode="Multiple" AutoPostBackOnReorder="true" EnableDragAndDrop="true"<br>                 OnDropped="RadListBox_Dropped" AllowTransfer="true" TransferToID="lstAssignedRemarkCode"<br>                     ButtonSettings-RenderButtonText="true" Localization-ToRight="Add" Localization-ToLeft="Remove"<br>               ButtonSettings-ShowTransferAll="False" ButtonSettings-ShowReorder="False" ButtonSettings-ShowDelete="False"
        ButtonSettings-HorizontalAlign="Center" ButtonSettings-VerticalAlign="Middle"
        ButtonSettings-AreaWidth="30px"
        DataTextField="RemarkCodeID,Name" DataTextFormatString="{0} - {1}" DataValueField="RemarkCodeID"    
        OnItemDataBound="lstAvailableRemarkCode_ItemDataBound">
        <ButtonSettings AreaWidth="100" />
    </telerik:RadListBox>

    But in code behind I get an error that source does not have a field 'RemarkCodeID,Name' at the DataBind:

    Is there a way I can Implement this?
  2. Bob
    Bob avatar
    4 posts
    Member since:
    Apr 2014

    Posted 02 May 2014 Link to this post

    OK, I am able to do this with Templates and combining the fields but now the remove puts a blank row in the original ListBox.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bob
    Bob avatar
    4 posts
    Member since:
    Apr 2014

    Posted 02 May 2014 in reply to Bob Link to this post

    Here is the updated html:
    <td colspan="2">
        <telerik:RadListBox runat="server" ID="lstAvailableRemarkCode" Width="600px"
        Height="300px" SelectionMode="Multiple" AutoPostBackOnReorder="true" EnableDragAndDrop="true"
        OnDropped="RadListBox_Dropped" AllowTransfer="true" TransferToID="lstAssignedRemarkCode"
        ButtonSettings-RenderButtonText="true" Localization-ToRight="Add" Localization-ToLeft="Remove"
        ButtonSettings-ShowTransferAll="False" ButtonSettings-ShowReorder="False" ButtonSettings-ShowDelete="False"
        ButtonSettings-HorizontalAlign="Center" ButtonSettings-VerticalAlign="Middle"
        ButtonSettings-AreaWidth="100px" DataValueField="RemarkCodeID"
        OnItemDataBound="lstAvailableRemarkCode_ItemDataBound">
         <ButtonSettings AreaWidth="100" />
             <ItemTemplate>
                <asp:Label ID="lblAvailableRemarkCode" runat="server" Text='<%# String.Format("{0} - {1}", Eval("RemarkCodeID"), Eval("Name")) %>' ></asp:Label>
             </ItemTemplate>
        </telerik:RadListBox>
    </td>
    <td>
        <telerik:RadListBox runat="server" ID="lstAssignedRemarkCode" Width="500px"
            Height="300px" SelectionMode="Multiple" AutoPostBackOnReorder="true" EnableDragAndDrop="true"
            OnDropped="RadListBox_Dropped">
        </telerik:RadListBox>
    </td>
  5. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 07 May 2014 Link to this post

    Hello Bob,

    Using the ItemTemplate of the RadListBox is the correct approach for achieving the desired rendering. However, I am afraid that I am not quite sure that I had fully understood the currently faced issue. Could you elaborate a bit more on the matter?

    Regards,
    Nencho
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top