對xml文件的記錄進行刪除
利用了datagrid控件的sortcommand事件對xml裡的記錄進行排序
email:
<%@page language=
<%@import namespace=
<%@import namespace=
<script language=
string xmlfile=
void page_load(Object obj
{
xpath=Server
if(!Page
{
Dataload(
}
}
void Dataload(string psort)
{
DataSet ds=new DataSet();
FileStream fs=new FileStream(xpath
ds
if(ds
{
Response
fs
Response
}
Trace
DataRow dr=ds
dr[
ds
Trace
//grid
//grid
DataView dv=new DataView(ds
Trace
if(psort
dv
grid
grid
fs
}
void grid_sort(Object obj
{
if(grid
Dataload(e
else
Response
}
void grid_edit(Object obj
{
grid
show_del(
Dataload(
}
void grid_cancel(Object obj
{
grid
show_del(
Dataload(
}
void grid_update(Object obj
{
int numcell=e
int currentrow=e
//int curr
Trace
//Trace
DataSet ds=new DataSet();
ds
DataRow dr;//表示DataTable中的一行信息
if(currentrow==
dr=ds
else
dr=ds
string[] str={
int j=
for(int i=
{
j=j+
string ctext;
ctext=((TextBox)e
dr[str[j]] = ctext;
Trace
}
if(currentrow==
{
Response
ds
}
ds
grid
show_del(
Dataload(
}
void show_del(string state)
{
string tmp=state;
switch(tmp)
{
case
grid
break;
case
grid
break;
default:
grid
break;//也要帶break
}
}
void initialize(Object obj
{
//e
if(e
{
LinkButton a
a
LinkButton a
a
if(a
a
if(a
a
}
}
void grid_del(Object obj
{
Response
Trace
int curr=e
DataSet ds=new DataSet();
ds
DataRow dr=ds
dr
ds
grid
Dataload(
}
</script>
<form runat=
<asp:datagrid id=
alternatingitemstyle
headerstyle
font
allowsorting=
onsortcommand=
oneditcommand=
oncancelcommand=
onupdatecommand=
onitemcreated=
ondeletecommand=
bordercolor=
>
<columns>
<asp:buttoncolumn text=
<asp:editcommandcolumn buttontype=
</columns>
</asp:datagrid>
</form>
xml文件(文件名:books
<?xml version=
<books>
<book>
<isbn>
<author>fefdw</author>
<title>
<category>
<comments>r
</book>
<book>
<isbn>
<author>ssdfdfe</author>
<title>fgregre</title>
<category>r
<comments>r
</book>
<book>
<isbn>
<author>ssdfdfe</author>
<title>fgregre</title>
<category>r
<comments>r
</book>
<book>
<isbn>
<author>Tom Peters</author>
<title>Circle of Innovation</title>
<category>marketing</category>
<comments>His most recent book is his best by far!</comments>
</book>
<book>
<isbn>
<author>Eli Goldthrait</author>
<title>The Goal</title>
<category>management</category>
<comments>Advocate of Theory of Constraints as applied to managment and optimization
</book>
<book>
<isbn>
<author>Jeff Cox
<title>Selling the Wheel</title>
<category>management</category>
<comments>Excellent Treatise/Novel on the entire Sales Cycle</comments>
</book>
<book>
<isbn>
<author>Alan Cooper</author>
<title>The Inmates Are Running The Asylum</title>
<category>management</category>
<comments>The father of Visual Basic and creator of the new art of Interaction Design
</book>
</books>
From:http://tw.wingwit.com/Article/program/net/201311/11966.html