CS代码:
DataSet ds = new DataSet();
ds.ReadXml(@Server.MapPath("~/App_Data/Users.xml"));
DataView dv = new DataView(ds.Tables[0]);
foreach (DataRowView drv in dv)
{
this.DropDownList1.Items.Add(new ListItem(drv["Name"].ToString(), drv["ID"].ToString()));
}
XML文件:
<?xml version="1.0" encoding="utf-8"?>
<NewDataSet>
<Table>
<ID>1</ID>
<Name>Csaspx1</Name>
</Table>
<Table>
<ID>2</ID>
<Name>Csaspx2</Name>
</Table>
<Table>
<ID>3</ID>
<Name>Csaspx3</Name>
</Table>
</NewDataSet>