zoukankan      html  css  js  c++  java
  • asp.net各种数据绑定方式

             绑定的属性必须是public
            绑定到简单属性:<%#UserName%>
            绑定到集合:<asp:ListBox id="ListBox1" datasource='<%# myArray%>' runat="server">
            绑定到表达式:<%#(class1.property1.ToString() + "," + class1.property2.ToString())%>
            绑定到方法返回值:<%# GetSafestring(str) %>
            绑定到Hashtable:<%# ((DictionaryEntry)Container.DataItem).Key%>
            绑定到ArrayList:<%#Container.DataItem %>
            若数组里里放的是对象则可能要进行必要的转换后再绑定如:
            <%#((对象类型)Container.DataItem).属性%>
           
             绑定到DataView,DataTable,DataSet:
            <%#((DataRowView)Container.DataItem)["字段名"]%>或
            <%#((DataRowView)Container.DataItem).Rows[0]["字段名"]%>
            要格式化则(这种方式效率比较低,原因是使用到了反射机制):
            <%#string.Format("格式",((DataRowView)Container.DataItem)["字段名"])%>
            <%#DataBinder.Eval(Container.DataItem,"字段名","格式")%>

            绑定到DataReader:
            <%#((IDataReader)Container.DataItem).字段名%>

           <%# ((DataRowView)Container.DataItem)["xxxx"]%> 

  • 相关阅读:
    array_count_values源码
    php 编译安装记录
    mysql 安装的过程做个记录
    初识highcharts 库
    php 不重新编译增加新扩展的方法
    备考PMP
    Beyond Compare4破解--写reg脚本删除注册表
    SourceTree 跳过登录
    正则 (?=exp)
    springmvc--处理器的返回参数
  • 原文地址:https://www.cnblogs.com/jacktu/p/575617.html
Copyright © 2011-2022 走看看