您的位置:首页 > 其它

步步为营VS 2008 + .NET 3.5(14) - XLINQ(LINQ to XML)之针对XML文件的添加、查询、更新和删除

2007-10-26 08:31 801 查看
[索引页]

[源码下载]

[align=center]步步为营VS 2008 + .NET 3.5(14) - XLINQ(LINQ to XML)之针对XML文件的添加、查询、更新和删除[/align]

作者:webabcd

介绍

以某一XML文件为例,XLINQ(LINQ to XML)之针对XML文件的添加操作、查询操作、更新操作和删除操作

示例

Sample.xml

<?xml version="1.0" encoding="utf-8"?>

<root>

<person name="webabcd" age="27" salary="33" />

</root>

Sample.aspx

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">

<p>

姓名:<asp:TextBox ID="txtName" runat="server"></asp:TextBox>

   年龄:<asp:TextBox ID="txtAge" runat="server"></asp:TextBox>

   薪水:<asp:TextBox ID="txtSalary" runat="server"></asp:TextBox>

<asp:Button ID="btnAdd" runat="server" Text="添加" OnClick="btnAdd_Click" />

</p>

<asp:GridView ID="gvPerson" runat="server" DataKeyNames="name" OnSelectedIndexChanged="gvPerson_SelectedIndexChanged"

OnRowDeleting="gvPerson_RowDeleting" OnRowCancelingEdit="gvPerson_RowCancelingEdit"

OnRowEditing="gvPerson_RowEditing" OnRowUpdating="gvPerson_RowUpdating">

<Columns>

<asp:CommandField ShowSelectButton="True" ShowEditButton="True" ShowDeleteButton="True">

</asp:CommandField>

</Columns>

</asp:GridView>

<br />

<asp:DetailsView ID="dvPerson" runat="server" DataKeyNames="name">

</asp:DetailsView>

</asp:Content>

Sample.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Xml.Linq;

public partial class LINQ_XLINQ_Sample : System.Web.UI.Page

OK

[源码下载]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐