using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Xml;
using System.IO;
using System.Collections;
public partial class t1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadGridView();
Response.Write(GetCurrentWebRoot());
foreach (var con in menuChks.Controls)
{
if (con is CheckBox)
{
CheckBox chk = con as CheckBox;
chk.Checked = true;
}
else if (con is Label) {
Label lb = con as Label;
lb.Text ="aaaa";
}
}
}
}
private void LoadGridView()
{
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("aa.xml"));
XmlNodeList list = doc.SelectNodes("students/student");
ArrayList datalist = new ArrayList();
foreach (XmlNode xnode in list)
{
CodeModel.Model.t1 t = new CodeModel.Model.t1();
XmlNode bh = xnode.SelectSingleNode("id");
XmlNode names = xnode.SelectSingleNode("name");
XmlNode ages = xnode.SelectSingleNode("age");
string id = bh.InnerText;
string name = names.InnerText;
string age = ages.InnerText;
t.Id = id;
t.Name = name;
t.Age = age;
datalist.Add(t);
}
GridView1.DataSource = datalist;
GridView1.DataBind();
////转换一个XML文件(本地\网络均可)为一个DataSet
//DataSet ds = new DataSet();
////ds=XMLDataSetConverter.ConvertXMLFileToDataSet(Server.MapPath("xmltodataset.xml"));
////ds=XMLDataSetConverter.ConvertXMLFileToDataSet("http://news.baidu.com/n?cmd=1class=sportnewstn=rss");
////foreach(DataRowrowinds.Tables[0].Rows)
////{
////stringname=row["name"].ToString();
////stringage=row["age"].ToString();
////}