DataTable dt = GetData();
int count = dt.Rows.Count;
DataTable dt_jishu = new DataTable();
DataTable dt_oushu = new DataTable();
dt_jishu = dt.Copy();
dt_oushu = dt.Copy();
for(int i = 1; i <= count/2; i++)
dt_jishu.Rows.RemoveAt(i);
for(int i= 0 ;i <= count/2-1; i++)
dt_oushu.Rows.RemoveAt(i);
如果有datalist,需要显示这样的格式:
1 a | 2 b
3 c | 4 d
6 e | 6 f
7 g | 8 h
this.dl1.DataSource = dt_jishu;
this.dl1.DataBind();
this.dl2.DataSource = d;
this.dl2.DataBind();
使用下面的语句分别作为 dl1、dl2的排序编号:
<%#((System.Web.UI.WebControls.DataListItem)Container).ItemIndex*2+1%>
<%#((System.Web.UI.WebControls.DataListItem)Container).ItemIndex*2+2%>