< %# Bind(“Subject”) % > // Bind fields < %# Container.DataItemIndex + 1% > // Realize automatic numbering < %# DataBinder.Eval(Container.DataItem, “[n]”) % > Commonly used methods (these 3 perform best) < %# DataBinder.Eval(Container.DataItem, “ColumnName”) % > < %# DataBinder.Eval(Container.DataItem, “ColumnName”, null) % > < %# DataBinder.Eval(Container, “DataItem.ColumnName”, null) % > Other USES < %# ((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). Attribute.ToString() % > // ToString() is not used if the attribute is string type Examples of DataBinder < %# DataBinder.Eval(Container.DataItem, “IntegerValue”, “{0:c}”) % > Formatting string parameters is optional. If the parameters are ignored, DataBinder.Eval returns the value of the object type,
// Displays 2 decimal places < %# DataBinder.Eval(Container.DataItem, “UnitPrice”, ”${0:F2}”) % >
//{0:G} indicates True or False < ItemTemplate > < asp:Image Width=“12” Height=“12” 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) The date {0:d} displays only the year, month and day {0: yyyy-ES106en-dd} display year, month and day in format {0:c} currency style < % # Container. DataItem (” price ”, “0.00} {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
The date {0:d} only shows the date of year, month and day {0: ES142en-ES143en-ES144en} display year, month and day in format
The style depends on the Settings in ES147en.config Currency Style {0:c} or {0:£0,000.00} Standard British currency style < system.web > < globalization requestEncoding=“utf-8” responseEncoding=“utf-8” culture=“en-US” uiCulture=“en-US” / > < /system.web > It shows £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 > The display is ¥3,000.10
{0: c} or string. Format (” {0: C} ”, price); American monetary style < system.web > < globalization requestEncoding=“utf-8” responseEncoding=“utf-8” / > < /system.web > The show is $3000.10