using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Xml;
public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DataSet mydsRead = new DataSet();
            mydsRead.ReadXml(Server.MapPath("XMLFile.xml"));
            GridView1.DataSource = mydsRead;
            GridView1.DataBind();
            DropDownList1.DataSource = mydsRead;
            DropDownList1.DataTextField = "仓库号";
            DropDownList1.DataBind();
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        XmlDocument doc = new XmlDocument();
        doc.Load(Server.MapPath("XMLFile.xml"));
        XmlNodeList nodes;
        XmlElement root = doc.DocumentElement;
        nodes = root.SelectNodes("descendant::仓库[仓库号='" + DropDownList1.Text .Trim () + "']");
        foreach (XmlNode node in nodes)
        {
            root.RemoveChild(node);
        }
        Response.Write("<script>alert('删除节点数据成功!')</script>");
        doc.Save(Server.MapPath("XMLFile.xml"));
        Response.Write("<script>location='Default.aspx'</script>");
    }
}
