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"]%> 

  • 相关阅读:
    监控里的主码流和子码流是什么意思
    监控硬盘容量计算
    一个能让你了解所有函数调用顺序的Android库
    电工选线
    oracle linux dtrace
    list all of the Oracle 12c hidden undocumented parameters
    Oracle Extended Tracing
    window 驱动开发
    win7 x64 dtrace
    How to Use Dtrace Tracing Ruby Executing
  • 原文地址:https://www.cnblogs.com/jacktu/p/575617.html
Copyright © 2011-2022 走看看