This is a migrated thread and some comments may be shown as answers.

Why can't I format this string? :S

3 Answers 74 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Iron
Paul asked on 21 Sep 2012, 06:27 PM
<%# 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. 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Sep 2012, 05:49 AM
Hi Paul,

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

Thanks,
Princy.
0
Paul
Top achievements
Rank 1
Iron
answered on 24 Sep 2012, 01:35 PM
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!
0
Princy
Top achievements
Rank 2
answered on 25 Sep 2012, 05:30 AM
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.
Tags
ListBox
Asked by
Paul
Top achievements
Rank 1
Iron
Answers by
Princy
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Iron
Share this question
or