DataGrid用的最多的数据源
DataGrid用的最多的数据源是:DataSet,DataView,DataTale
是否用过Arrarylist,HashTable,SortedList????
eg1:ArrayList al = new ArrayList();
al.Add(3);
al.Add(2);
al.Add(4);
al.Add(1);
this.DataGrid1.DataSource = al;
this.DataGrid1.DataBind();
是不是页眉为Item要想改为自己想要的结果:
在ItemDataBound事件中:
if(e.Item.ItemType == ListItemType.Header)
{
e.Item.Cells[0].Text="想显示的页眉";
}
eg2:SortedList st = new SortedList();
st.Add(1,2);
st.Add(2,3);
st.Add(3,5);
st.Add(4,4);
this.DataGrid1.DataSource = st;
this.DataGrid1.DataBind();
这将什么都没有!绑定两列:数据字段分别为:Value,Key
将呈现你想要的结果~!~

浙公网安备 33010602011771号