您的位置:首页 > 其它

DataView,Repeater,模板

2009-07-15 00:10 211 查看
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(分割)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: