下面是后台程序
protected void DataList1_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
switch (e.CommandName)
{ case "edit":
DataList1.EditItemIndex = e.Item.ItemIndex;
ShowBooks_Bind();
break;
case "cancel":
DataList1.EditItemIndex = -1;
ShowBooks_Bind();
break;
case "update":
doc.Load(patch);
XmlNodeList nodelist = doc.SelectNodes("BookStore/Book[name='" + e.CommandArgument + "']");//e.CommandArgument是前台邦定的固定ID
foreach (XmlNode xn in nodelist)
{
XmlElement xe = (XmlElement)xn;
XmlNodeList nls = xe.ChildNodes;
foreach (XmlNode xn1 in nls)
{
XmlElement xe2 = (XmlElement)xn1;
if (xe2.Name == "title")
{
xe2.InnerText = ((TextBox)e.Item.FindControl("tb1")).Text;
break;
}
}
break;
}
doc.Save(patch);
DataList1.EditItemIndex = -1;
ShowBooks_Bind();
break;
}
}
下面是XML
<?xml version="1.0" encoding="utf-8"?>
<BookStore>
<Book>
<number>20090222175144</number>
<title>测试1</title>
<type>SQL数据库</type>
<author>Test</author>
<price>58</price>
<time>200902221751</time>
</Book>
</BookStore>
protected void DataList1_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
switch (e.CommandName)
{ case "edit":
DataList1.EditItemIndex = e.Item.ItemIndex;
ShowBooks_Bind();
break;
case "cancel":
DataList1.EditItemIndex = -1;
ShowBooks_Bind();
break;
case "update":
doc.Load(patch);
XmlNodeList nodelist = doc.SelectNodes("BookStore/Book[name='" + e.CommandArgument + "']");//e.CommandArgument是前台邦定的固定ID
foreach (XmlNode xn in nodelist)
{
XmlElement xe = (XmlElement)xn;
XmlNodeList nls = xe.ChildNodes;
foreach (XmlNode xn1 in nls)
{
XmlElement xe2 = (XmlElement)xn1;
if (xe2.Name == "title")
{
xe2.InnerText = ((TextBox)e.Item.FindControl("tb1")).Text;
break;
}
}
break;
}
doc.Save(patch);
DataList1.EditItemIndex = -1;
ShowBooks_Bind();
break;
}
}
下面是XML
<?xml version="1.0" encoding="utf-8"?>
<BookStore>
<Book>
<number>20090222175144</number>
<title>测试1</title>
<type>SQL数据库</type>
<author>Test</author>
<price>58</price>
<time>200902221751</time>
</Book>
</BookStore>
解决方案 »
- asp.net用户控件赋值
- 100分求助:二级站点共用一个cookie的问题
- 关于委托跟out
- 调查一下:你们在VS2005中是用objectDataSouce编程还是仍然使用ADO.NET编程?我公司一定要我使用objectDataSouce编程啊。晕死了。。
- asp.net菜鸟问题!急
- 为什么我的vs2005编译一个web项目要等好长时间?
- 如何点击页面连接的时候运行客户端的程序?
- 定做DropDownList无刷新三级联动菜单,很急的项目,先送上50分,可以现金交易
- 一个购物车问题,需要急救
- mapxtreme 2008 状态管理 SaveZoomCenterState
- 大家是怎么防注入的呀?????
- 大家帮忙看一下.下面的代码为什么不能实现单击左键和右键时提示一下呀?
一:没有可写权限
二:你获取xml节点列表是没有获取到对应的元素,建议调试看一下。