62,046
社区成员
发帖
与我相关
我的任务
分享
namespace testWebProject
{
public partial class index : System.Web.UI.Page
{
public class user
{
private string userid;
public string Userid
{
get { return userid; }
set { userid = value; }
}
private string username;
public string Username
{
get { return username; }
set { username = value; }
}
private string userpwd;
public string Userpwd
{
get { return userpwd; }
set { userpwd = value; }
}
public user(string userid, string username, string userpwd)
{
this.userid = userid;
this.username = username;
this.userpwd = userpwd;
}
}
protected void Page_Load(object sender, EventArgs e)
{
List<user> userCollection = new List<user>();
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(Server.MapPath("~/XMLFile1.xml"));
System.Xml.XmlNodeList collection = doc.SelectNodes("/xml_user/user");
foreach (System.Xml.XmlNode node in collection)
{
userCollection.Add(new user(node.Attributes["id"].Value, node.ChildNodes[0].InnerText, node.ChildNodes[1].InnerText));
}
GridView1.DataSource = userCollection;
GridView1.DataBind();
}
}
}