zoukankan      html  css  js  c++  java
  • GridView绑定技巧终结者

    gridview列 数字、货币和日期 显示格式
    形式 语法 结果 注释
    数字 {0:N2} 12.36  
    数字 {0:N0} 13  
    货币 {0:c2} $12.36  
    货币 {0:c4} $12.3656  
    货币 "¥{0:N2}" ¥12.36  
    科学计数法 {0:E3} 1.23E+001  
    百分数 {0:P} 12.25% P and p present the same.
    日期 {0:D} 2006年11月25日  
    日期 {0:d} 2006-11-25  
    日期 {0:f} 2006年11月25日 10:30  
    日期 {0:F} 2006年11月25日 10:30:00  
    日期 {0:s} 2006-11-26 10:30:00  
    时间 {0:T} 10:30:00

    <1>绑定日期

    <asp:BoundField DataField="AddDate" DataFormatString="{0:yyyy年MM月dd日}" HeaderText="添加日期" SortExpression="AddDate" />

     <2>绑定价格

    <ItemTemplate><asp:TextBox Width="60" ID="Price" runat="server" Text='<%# Bind("Price","{0:n}") %>'></asp:TextBox></ItemTemplate>

    <3>绑定货币

    <ItemTemplate><asp:Label ID="Label1" runat="server" Text='<%# Bind("BookPrice", "{0:c}") %>'></asp:Label></ItemTemplate>

    <4>带参数的链接

    <asp:HyperLinkField Text="修改" DataNavigateUrlFields="catenaid" DataNavigateUrlFormatString="addBookCatena.aspx?edit={0}" HeaderText="修改" />
     <ItemTemplate><a runat="server" target="_blank" href='<%#"~/bookinfo.aspx?bookID="+Eval("bookID") %>' ><%# Eval("bookName"%></a></ItemTemplate>

    <5>绑定bool变量
     <ItemTemplate><%# (bool)Eval("IsMain"? "<span style='color: Green'>YES</span>" : "<span tyle='color: Red'>NO</span>" %></ItemTemplate>

    <6>鼠标提示
     <ItemTemplate><asp:Image ID="Image1" runat="server" AlternateText='<%# Eval("ImageURL") %>' ImageUrl='<%# Eval("ImageURL") %>' /> </ItemTemplate>

    <7>函数绑定
    <TD colspan="5" valign="middle" style="height: 24px">订单号:<%# Eval("orderID"%><%# DataFormat.isTg((bool)Eval("isTg"))%></TD>
    函数定义如下:
    Code

    <8>绑定JS
     <asp:TemplateField>
           
    <HeaderTemplate><input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);" runat="server" type="checkbox" /></HeaderTemplate>
           
    <ItemTemplate><asp:CheckBox ID="chk" runat="server" /></ItemTemplate>
     
    </asp:TemplateField>
    全选的JS代码

  • 相关阅读:
    winform把所有dll打包成一个exe
    Windows10+Python3下安装NumPy+SciPy+Matplotlib
    Windows10+Python3+BeautifulSoup4 安装
    解决:无法在发送 HTTP 标头之后进行重定向。 跟踪信息: 在 System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>……
    "请求被中止: 未能创建 SSL/TLS 安全通道"解决办法
    被“1”和“l”给坑了
    谁把我的代码覆盖了
    jQueryUI datepicker 报错: TypeError: inst is undefined
    VS 附加不上w3wp.exe
    MySQL性能调优与架构设计——第 18 章 高可用设计之 MySQL 监控
  • 原文地址:https://www.cnblogs.com/yank/p/1169041.html
Copyright © 2011-2022 走看看