Why can't I format this string? :S

4 posts, 0 answers
  1. Paul
    Paul avatar
    27 posts
    Member since:
    Feb 2012

    Posted 21 Sep 2012 Link to this post

    <%# DataBinder.Eval(Container, "Attributes['Price']")%>

    For some reason... maybe because of the use of attributes?... I cannot for the life of me get this to format as currency. 
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2012 Link to this post

    Hi Paul,

    Try setting the format string as shown below.
    aspx:
    <%# DataBinder.Eval(Container.DataItem, "Price", "{0:C}") %>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Paul
    Paul avatar
    27 posts
    Member since:
    Feb 2012

    Posted 24 Sep 2012 Link to this post

    Ah Princy... you ARE a prince! 

    "We" (meaning you of course), are sooooooooooo close.  That does work, sort of.  The second half of the problem (and I didn't think there would be a second half but there is), is that there are two related listboxes, with transfer enabled between them.  Your formatting works perfectly on the "first" listbox, but not on the "second" one, for reasons way over my head.  If/when you are inclined to give me more of your time, any suggestions on the second box?  Anything I've tried either blanks out the field or leaves it unchanged, in which case it becomes blanked out when I transfer back to the source.  I suppose I could live without being able to transfer back if that becomes a big issue but I'm completely confused now...


    Thanks again, I'm very grateful for your help!
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Sep 2012 Link to this post

    Hi Paul,

    Unfortunately I cannot replicate the issue at my end. The format string is working as expected in the second listbox. Here is the sample code.
    aspx:
    <telerik:RadListBox ID="RadListBox1" runat="server" DataSourceID="SqlDataSource2" EnableDragAndDrop="true" AllowTransfer="true" TransferToID="RadListBox2" >
     <ItemTemplate>
          <%# DataBinder.Eval(Container.DataItem, "EmployeeID", "{0:C}") %>
     </ItemTemplate>
    </telerik:RadListBox>
    <telerik:RadListBox ID="RadListBox2" runat="server" DataSourceID="SqlDataSource2">
       <ItemTemplate>
           <%# DataBinder.Eval(Container.DataItem, "BirthDate", "{0:dd-MM-yyyy}")%>
       </ItemTemplate>
    </telerik:RadListBox>

    Thanks,
    Princy.
Back to Top