111,057
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
public void BindDataList()
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("Softs.xml"));
DataTable dt = new DataTable();
dt.Columns.Add("name", typeof(string));
dt.Columns.Add("pic", typeof(string));
dt.Columns.Add("Memo", typeof(string));
dt.Columns.Add("Url", typeof(string));
/////还可以采用下面的任一方法,推荐/////
dt = ds.Tables[0].Clone();//copy the structure of ds.Table[0];
dt = ds.Tables[0].Copy();//copy the structure and datas of ds.Table[0];
//////////////////////////////////////////////////
DataRow[] Rows = ds.Tables[0].Select("Type='App'");
DataRow dr;
foreach (DataRow row in Rows)
{
dr = dt.NewRow();
dr["pic"] = row[0].ToString();
dr["Url"] = row[1].ToString();
dr["Memo"] = row[2].ToString();
...........
dt.Rows.Add(dr);
}
// DataList1.DataSource = ds.Tables[0].DefaultView;
DataList1.DataSource = dt.DefaultView;
//ds.Tables[0].Select("Type='Application'").;
DataList1.DataBind();
}