Need help with Eval inside DataList

This should be simple enough, and I blame it primarily on my inexperience working with DataLists, Repeaters, etc.

I have a DataList control that I use to display items in a shopping cart. Everything goes well with my binding of various controls using Eval ("ColumnName") until I get to the price column.

My goal is to do this:

Total cost of goods

$ 20.00 ($ 5 each)

I am trying to accomplish this with two Lab Label controls inside a table cell:

<asp:Label ID="lblTotalItemCost" runat="server" Text='<%# Eval("TotalItemCost") %>'>
</asp:Label>
<br />
<asp:Label ID="lblPrice" runat="server" Text='(<%# Eval("Price")%> each)' >
</asp:Label>

Unfortunately, it displays the column as:

Total cost of goods

$ 20.00 (<% # Eval ("Price")%> each)

, "server tag not wellform". , , .

+2
2

:

Text='<%#"(" + Eval("Price").ToString() + " each)"%>'
+3

? , #, VB.NET

<asp:Label ID="lblPrice" runat="server" Text='<%# Eval("Price", "({0} each)"%>' />
+1

Source: https://habr.com/ru/post/1708370/


All Articles