zoukankan      html  css  js  c++  java
  • ASP.Net中的关于数据绑定

    1. 绑定标签   <%#   ……  %>  可绑定标签属性值,表达式,方法的结果及数据源等。

          a. 绑定属性之label的Text属性值  :

                      <asp: label1 ID="labtxt"  Text="<%#  DataTime.Now.ToShortString()  %>"  >

                  this.label1.DataBind();***************后台代码千万不能少

          b.绑定变量

                  后台代码类中定义一变量    protected  Color  bgcolor=Color.FromArgb(180,140,210);

                  前台  <asp: label1 ID="labtxt" BackColor="<%#  bgcolor %>" runat="server">

                   this.labtxt.DataBind();

           c.绑定常量

                  后台    protected  int  a=15;

                           protected  int  b=10;

                    <td>  a+b=<%# a+b %> <td>

                    this.DataBind();

           d.绑定 方法

                 在后面写个方法  protected string  GetDate(){……}

                 在前台    <td>  今天:<%#  GetData()  %> </td> 

                  this.DataBind();

           e.绑定 数组集合

                    Protected string[]  strarray={"acb","def","xyz"};

                    < asp: DropDownList  DataSource="<%# strarray %>"   >

                          this.DataBind();        

         

  • 相关阅读:
    XML的语法
    dell omsa 监控,Nrpe信号量泄露
    cx_Oracle 报错 Reason: image not found
    cx_Oracle 中文乱码问题解决
    High Memory in the Linux Kernel
    使用二分法查找mobile文件中区号归属地
    mysql 导出csv
    行删除按钮功能
    vsftp 根据用户设置
    安装zabbix报错configure: error: libcurl library not found
  • 原文地址:https://www.cnblogs.com/yingger/p/2451224.html
Copyright © 2011-2022 走看看