Some Usage of ASP. NET eval Value Calculation

Source: Internet
Author: User
<% # BIND ("subject") %> // bind the field <% # container. dataitemindex + 1%> // implement automatic number <% # databinder. eval (container. dataitem, "[N]") %> commonly used methods (which have the 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 )). attribute. tostring () %> // If the attribute is of the string type, you do not need tostring (). databinder. eval usage example <% # databinder. eval (container. dataitem, "integervalue", "{0: c}") %> the format string parameter is optional. If the parameter is ignored, databinder. eval returns the object type value, // displays two 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 () {0: d} date only shows year month day {0: yyyy-mm-dd} display year month day {0: c} currency style by format <% # container. dataitem ("price", "{0: ¥ #,## 0.00}") %> <% # 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.2420.e + 004 F fixed point {0: f} 1.42-12400.00g 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} display year month day style depends on Web. set {0: c} or {0: 00000,000.00} currency style in config. Standard British currency style <system. web> <globalization requestencoding = "UTF-8" responseencoding = "UTF-8" Culture = "En-us" uiculture = "En-us"/> </system. web> displayed as listen 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> display: ¥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> displayed as $3,000.10

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.