<%# bind ("Subject")%>//bound field
<%# Container.dataitemindex + 1%>//implementation automatic numbering
<%# DataBinder.Eval (Container.DataItem, "[n]")%>
commonly used methods (these three best performance)
<%# DataBinder.Eval (Container.DataItem, "ColumnName")%>
<%# DataBinder.Eval (Container.DataItem, "ColumnName", null)%>
<%# DataBinder.Eval (Container, "Dataitem.columnname", null)%>
Other usage
<%# ((DataRowView) container.dataitem) ["ColumnName"]%>
<%# ((DataRowView) Container.DataItem). row["ColumnName"]%>
<%# ((DataRowView) container.dataitem) ["Adtitle"]%>
<%# ((DataRowView) Container.DataItem) [n]%>
<%# ((DbDataRecord) Container.DataItem) [0]%>
<%# ((custom type) Container.DataItem). property. ToString ()%>//If the attribute is a string type do not use ToString ()
DataBinder.Eval Usage Examples
<%# DataBinder.Eval (Container.DataItem, "IntegerValue", "{0:c}")%>
The format string parameter is optional. If the argument is omitted, DataBinder.Eval returns the value of the object type.
Show two decimal places
<%# DataBinder.Eval (Container.DataItem, "UnitPrice", "${0:f2}")%>
{0:g} represents true or False
<ItemTemplate>
<asp:image width= "height=" border= "0" runat= "Server"
Alternatetext= ' <%# DataBinder.Eval (Container.DataItem, "discontinued", "{0:g}")%> '
Imageurl= ' <%# DataBinder.Eval (Container.DataItem, "discontinued", "~/images/{0:g}.gif")%> '/>
</ItemTemplate>
Conversion type
((String) DataBinder.Eval (Container, "DATAITEM.P_SHIP_TIME_SBM8")). Substring (4,4)
{0:D} Date only shows year month day
{0:YYYY-MM-DD} Displays the date of year by format
{0:C} currency style
<% #Container. DataItem ("Price", "{0:¥#,# #0.}")%>
<%# DataBinder.Eval (Container.DataItem, "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} system.formatexception-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 system.formatexception
x hexadecimal {0:x4} system.formatexception cf90
{0:D} Date only shows year month day
{0:YYYY-MM-DD} Displays the date of year by format
Styles depend on the settings in the Web.config
{0:c} or {0:£0,000.00} currency style standard English currency style
<system.web>
<globalization requestencoding= "Utf-8" responseencoding= "Utf-8" culture= "en-us" uiculture= "en-US"/>
</system.web>
Show as £3,000.10
{0:C} or string. Format ("{0:c}", price); Chinese currency style
<system.web>
<globalization requestencoding= "Utf-8" responseencoding= "Utf-8" culture= "ZH-CN" uiculture= "ZH-CN"/>
</system.web>
Show as ¥3,000.10
{0:C} or string. Format ("{0:c}", price); American Currency Style
<system.web>
<globalization requestencoding= "Utf-8" responseencoding= "Utf-8"/>
</system.web>
Show as $3,000.10