• Eavl的使用( gridview绑定多个值,调用函数)


    在gridview绑定多个值
    第一种:
    <asp:TemplateField HeaderText="GP Percentage"> <ItemTemplate> <asp:Label ID="lbl_GP" runat="server" Text='<%#string.Format("{0:F3}",showGPPercentage(Eval("B2BGP"),Eval("InvoiceAmt"))) %>'></asp:Label> </ItemTemplate> </asp:TemplateField> 第二种: 在sql里做处理
    前台aspx页面调用BLL函数
    导入命名空间:
    在.aspx页面<%@ Import Namespace="BLL" %>
    或者在配置文件(web.config)中设置, 所以页面都可用
    <system.web>  
    ......  
        <pages>  
            <namespaces>  
                <add   namespace="System"   />  
                <add   namespace="System.Collections"   />  
                <add   namespace="System.Collections.Specialized"   />  
                <add   namespace="System.Configuration"   />  
                <add   namespace="System.Text"   />  
                <add   namespace="System.Text.RegularExpressions"   />  
                <add   namespace="System.Web"   />  
                <add   namespace="System.Web.Caching"   />  
                <add   namespace="System.Web.SessionState"   />  
                <add   namespace="System.Web.Security"   />  
                <add   namespace="System.Web.Profile"   />  
                <add   namespace="System.Web.UI"   />  
                <add   namespace="System.Web.UI.WebControls"   />  
                <add   namespace="System.Web.UI.WebControls.WebParts"   />  
                <add   namespace="System.Web.UI.HtmlControls"   />  
            </namespaces>  
        </pages>  
    ...  
    </system.web>
    <asp:TextBox ID="txt_qty"  width="80px" runat="server" Text='<%#MyNumber.showInt_or_Empty(Eval("qty")) %>'></asp:TextBox>
    使用Eval()绑定数据时使用三元运算符
    
    ASP.NET邦定数据“<%#Eval("Sex")%>”运用三元运算符: 
    <%#(Eval("Sex", "{0}") == "01") ? "" : ""%>
     
    
    <%#(Convert.ToInt32(Eval("NowDate","{0}"))>60)?Convert.ToInt32(Eval("NowDate"))/60+"小时前":Eval("NowDate").ToString()+"分钟前"%><span class="style3">  来自优酷网</span></td>
    
    
     ImageUrl='<%#(Eval("Use_Pic", "{0}").ToString() =="Null")? "Head/head.png" : Eval("Use_Pic")%>' 
     
    数据绑定时多余的长度用“……”代替:
    <asp:LinkButton ID="linkMessage" ForeColor="Black" runat="server" Text='<%#Eval("NewsTitle").ToString().Length>10?Eval("NewsTitle").ToString().Substring(0,10)+"……":Eval("NewsTitle")%>'/>
     
    Eval绑定方法:
    <asp:TemplateField HeaderText="付费状态">
        <ItemTemplate>
           <asp:Label runat="server" ID="lbPayStatus" Text='<%#BLL.OrderBLL.GetPayStatus(Convert.ToInt32(Eval("id"))) %>'/>
        </ItemTemplate>
       </asp:TemplateField>
     
    多条件绑定:
    <asp:TemplateField HeaderText="一审结果">
        <ItemTemplate>
         <%#Eval("hg_A").ToString()=="1"?"通过":Eval("hg_A").ToString()=="2"?"不通过":""%>
         </ItemTemplate>
     </asp:TemplateField>
  • 相关阅读:
    android HashMap的几种遍历方法
    Android android:windowSoftInputMode属性详解
    Linux环境变量的设置和查看方法
    linux 定时执行shell脚本
    Linux 定时执行shell脚本_crontab
    Linux下修改字符集,转自
    解决Linux下Oracle中文乱码的一些心得体会 ,转自
    SSH Secure Shell Client连接Linux 命令行显示中文乱码问题 和oracle 查询数据中文乱码问题
    VMware 虚拟机(linux)增加根目录磁盘空间 转自
    linux 虚机增加硬盘大小 转自
  • 原文地址:https://www.cnblogs.com/suan1717/p/6169235.html
Copyright © 2020-2023  润新知