<%# Bind("Subject") %> //Binding fields
<%# + 1%> //Implement automatic numbering
<%# (, "[n]") %>
The usual methods (these three perform the best)
<%# (, "ColumnName") %>
<%# (, "ColumnName", null) %>
<%# (Container, "", null) %>
Other usages
<%# ((DataRowView))["ColumnName"] %>
<%# ((DataRowView)).Row["ColumnName"] %>
<%# ((DataRowView))["adtitle"] %>
<%# ((DataRowView))[n] %>
<%# ((DbDataRecord))[0] %>
<%# ((((custom type))).Properties.ToString() %>//If the property is a string type, you don't need ToString()
Usage example
<%# (, "IntegerValue", "{0:c}") %>
Format string parameters are optional. If the parameter is ignored, return the value of the object type.
//Show two decimal places
<%# (, "UnitPrice", "${0:F2}") %>
//{0:G} means to display True or False
<ItemTemplate>
<asp:Image Width="12" Height="12" Border="0" runat="server"
AlternateText='<%# (, "Discontinued", "{0:G}") %>'
ImageUrl='<%# (, "Discontinued", "~/images/{0:G}.gif") %>' />
</ItemTemplate>
//Convert type
((string)(Container, "DataItem.P_SHIP_TIME_SBM8")).Substring(4,4)
{0:d} Date only shows year, month, day
{0:yyyy-mm-dd} Display year, month and day by format
{0:c} Currency Style
<%#("price","{0:¥#,##0.00}")%>
<%# (,"Company_Ureg_Date","{0:yyyy-M-d}")%>
Specifier Type Format Output (Passed Double 1.42) Output (Passed Int -12400)
c Currency {0:c} $1.42 -$12,400
d Decimal {0:d} -12400
e Scientific {0:e} 1.420000e+000 -1.240000e+004
f Fixed point {0:f} 1.42 -12400.00
g General {0:g} 1.42 -12400
n Number with commas for thousands {0:n} 1.42 -12,400
r Round trippable {0:r} 1.42
x Hexadecimal {0:x4} cf90
{0:d} Date only shows year, month, day
{0:yyyy-mm-dd} Display year, month and day by format
The style depends on the settings in
{0:c} or {0:£0,000.00} Currency Style Standard British Currency Style
<>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US" />
</>
Shown as £3,000.10
{0:c} or ("{0:C}", price); Chinese currency style
<>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="zh-cn" uiCulture="zh-cn" />
</>
Shown as ¥3,000.10
{0:c} or ("{0:C}", price); US currency style
<>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</>
Shown as $3,000.10
<%# + 1%> //Implement automatic numbering
<%# (, "[n]") %>
The usual methods (these three perform the best)
<%# (, "ColumnName") %>
<%# (, "ColumnName", null) %>
<%# (Container, "", null) %>
Other usages
<%# ((DataRowView))["ColumnName"] %>
<%# ((DataRowView)).Row["ColumnName"] %>
<%# ((DataRowView))["adtitle"] %>
<%# ((DataRowView))[n] %>
<%# ((DbDataRecord))[0] %>
<%# ((((custom type))).Properties.ToString() %>//If the property is a string type, you don't need ToString()
Usage example
<%# (, "IntegerValue", "{0:c}") %>
Format string parameters are optional. If the parameter is ignored, return the value of the object type.
//Show two decimal places
<%# (, "UnitPrice", "${0:F2}") %>
//{0:G} means to display True or False
<ItemTemplate>
<asp:Image Width="12" Height="12" Border="0" runat="server"
AlternateText='<%# (, "Discontinued", "{0:G}") %>'
ImageUrl='<%# (, "Discontinued", "~/images/{0:G}.gif") %>' />
</ItemTemplate>
//Convert type
((string)(Container, "DataItem.P_SHIP_TIME_SBM8")).Substring(4,4)
{0:d} Date only shows year, month, day
{0:yyyy-mm-dd} Display year, month and day by format
{0:c} Currency Style
<%#("price","{0:¥#,##0.00}")%>
<%# (,"Company_Ureg_Date","{0:yyyy-M-d}")%>
Specifier Type Format Output (Passed Double 1.42) Output (Passed Int -12400)
c Currency {0:c} $1.42 -$12,400
d Decimal {0:d} -12400
e Scientific {0:e} 1.420000e+000 -1.240000e+004
f Fixed point {0:f} 1.42 -12400.00
g General {0:g} 1.42 -12400
n Number with commas for thousands {0:n} 1.42 -12,400
r Round trippable {0:r} 1.42
x Hexadecimal {0:x4} cf90
{0:d} Date only shows year, month, day
{0:yyyy-mm-dd} Display year, month and day by format
The style depends on the settings in
{0:c} or {0:£0,000.00} Currency Style Standard British Currency Style
<>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US" />
</>
Shown as £3,000.10
{0:c} or ("{0:C}", price); Chinese currency style
<>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" culture="zh-cn" uiCulture="zh-cn" />
</>
Shown as ¥3,000.10
{0:c} or ("{0:C}", price); US currency style
<>
<globalization requestEncoding="utf-8" responseEncoding="utf-8" />
</>
Shown as $3,000.10