DataView,Repeater,模板

  1.DataView 的作用

      可以公开表中具有不同的排序顺序的数据
      mydv.Sort=" fbane Asc,fid Asc"
      可以按行状或基于筛选器表达式来筛选数据
      mydv/RowFilter=" num>100"

      设置背景:
     if(e.Row.Rowtype==DataControlRowType.DataRow)
     {
         e.Row.Attributes.add("onmouseover","currentcol=this.style.background='#coc0ff';this.style.cursor='hand'")
         e.Row.Attributes.add("onmouseover","currentcol=this.style.background='#cocfff';this.style.cursor='hand'")
     }
      设置单元格的背景色:
        e.Row.Cells[0]. BackColor=System.Drwaing.Color.Red;

 

  2.DataGrid 读取xml中的数据
       FileStream fs=new FileStream (Server.MapPath("Student.xml"),FileMode.Open,FileAccess.Read);//文件流
       StreamReader st=new StreamReader (fs);//基于文件流读取纯文本(xml就是纯文本)
       DataSet set=new DataSet ();
       set.ReadXml(st);       //将xml数据读入dataset中形成一个表
       this.GridView1.DataSource=set;
       this.GridView1.DataBind();

 

  3.可绑定的数据类型
      简单属性
          <%# Textname.text%> 绑定表达式 服务端运行
      集合
      表达式
      方法调用结果

 

  4.模板(注意运用于DataGrid,DataList,Repeater)

        设置属性 ,使用样式
        模板是一组html元素和控件,他们构成组件特定部分的布局
      
        Repeater(循环显示数据)

           支持的模板 ItemTemplate(项) , Alternatingitemtemplate(交替),Headertemplate
            Footertemplate,Separatortemplate(分割)
           
      

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值