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();        

         

  • 相关阅读:
    shell getopt getopts获取参数
    apache+svn+ladp认证
    SVN 迁移项目分支
    iptables 优先级
    很实用的一篇HTTP状态码
    套路还在——矩阵计算估值
    CU上看到的一个简单的算法帖子
    linux下服务端实现公网数据转发
    c++接口实现与分离(转载)
    c++继承概念
  • 原文地址:https://www.cnblogs.com/yingger/p/2451224.html
Copyright © 2011-2022 走看看