DataView,Repeater,模板

来源:互联网 发布:linux 命令行图形界面 编辑:程序博客网 时间:2024/05/21 17:37

  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(分割)
           
      

 

原创粉丝点击