使用aspx和XML文件进行更新 [英] updating with aspx and XML file

查看:66
本文介绍了使用aspx和XML文件进行更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此先感谢您的帮助...我有一个XML数据文件(好的

形成)我需要放入我网站的app_data文件夹。我想要在我的网站上有一个.aspx表单,它只有两个

文本框(对应我文件中的两个XML字段),并且

提交

按钮将更新文件。关于代码使用的任何线索?


我最熟悉DataAdapter / DataSet模型并使用

SQLserver文件并插入INSERT查询更新。这个

是否也可以在XML文件上使用
?可能有更好的方法,但只是好奇

如果这个模型可以使用XML。

谢谢!

解决方案

6月5日9:31 pm,slinky< campbellbrian2 ... @ yahoo.comwrote:


提前致谢我的帮助...我有一个XML数据文件(好的

形成)我需要放入我网站的app_data文件夹。我想要在我的网站上有一个.aspx表单,它只有两个

文本框(对应我文件中的两个XML字段),并且

提交

按钮将更新文件。关于代码使用的任何线索?


我最熟悉DataAdapter / DataSet模型并使用

SQLserver文件并插入INSERT查询更新。这个

是否也可以在XML文件上使用
?可能有更好的方法,但只是好奇

如果这个模型可以使用XML。

谢谢!



将myDataSet调暗为新数据集()

myDataSet.ReadXml(Server.MapPath(" books.xml"))

http://aspnet.4guysfromrolla.com/articles /052902-1.aspx

http://www.google.com/search?hl=en&q...et+xml+asp.net


谢谢! http://aspnet.4guysfromrolla.com/articles/052902-1。 aspx 是一个很棒的网站......但是我从网站上尝试了下面的一些代码(我是

a使用Visual的学生新手Web Developer Express 2005)。我将以下内容粘贴到一个空白的.aspx页面,将您的books.xml文件粘贴到我网站上的

app_data文件夹中,重新构建,并删除一些错误,我

尝试在浏览器中查看它并收到服务器错误:


这里是我的aspx:


<%@ import Namespace =" System.Data" %>

< script runat =" server">

sub Page_Load(发件人为Object,e为EventArgs)

Dim myDataSet as New DataSet()

myDataSet.ReadXml(Server.MapPath(" books.xml"))

dgBooks.DataSource = myDataSet

dgBooks.DataBind()

dgBooksPretty.DataSource = myDataSet

dgBooksPretty.DataBind()

end sub

< / script>


< head id =" Head1" runat =" server">

< title> StartPage< / title>

< / head>

< body>

< b> XML文件的内容

< a href =" /demos/books.xml">< code> books.xml< / code>< / a>< / b>< br />

< asp:datagrid id =" dgBooks" RUNAT = QUOT;服务器" />


< p align =" center">

< b>更好地查找XML文件的DataGrid表示
< a href =" /demos/books.xml">< code> books.xml< / code>< / a>< / b>< br />

< / p>

< asp:datagrid id =" dgBooksPretty" runat =" server"

AutoGenerateColumns =" False"

Font-Name =" Verdana"

Font-Size ="小

Horizo​​ntalAlign ="中心

ItemStyle-BackColor =" #FFFFCC"

AlternatingItemStyle-BackColor =" #EEEEEE" >


< HeaderStyle BackColor =" Red" Horizo​​ntalAlign =" Center"

ForeColor =" White"字体-粗体="真" />


< Columns>

< asp:BoundColumn HeaderText =" Title"数据字段= QUOT;标题" />

< asp:BoundColumn HeaderText ="作者"数据字段= QUOT;作者" />

< asp:BoundColumn HeaderText =" Year"数据字段= QUOT;年" />

< / Columns>

< / asp:datagrid>


< / body>

< / html>


这里是我的xml文件:


<?xml version = " 1.0"编码= QUOT; UTF-8英寸?>

< books>

- < book>

< title>在21天内自学Active Server Pages 3.0< / title>

< author> Mitchell< / author>

< year> 1999< / year>

< / book>

- < book>

< title>设计Active Server Pages< / title>

< author> Mitchell< / author>

< year> 2000< / year>

< / book>

- < book>

< title> ASP.NET:提示,教程和代码< / title>

< author> Mitchell< / author>

< year> 2001< / year>

< / book>

- < book>

< title> ASP Unleashed< / title>

< author> Walther< / author>

< year> 1998< / year>

< / book>

- < book>

< title> ASP.NET Unleashed< / title>

< author> Walther< / author >

< year> 2002< / year>

< / book>

- < book>

< title>创建数据驱动的ASP.NET应用程序< / title>

< author> Seven< / author>

< year> 2002< /年>

< / book>

< / books>


>

将myDataSet调暗为新数据集()

myDataSet.ReadXml(Server.MapPath(" books.xml"))

=nofollowhref =http://aspnet.4guysfromrolla.com/articles/052902-1.aspxtarget =_ blank> http://aspnet.4guysfromrolla.com/articles/052902-1.aspx

http://www.google.com/search?hl=en&q...et+xml+asp.net



< blockquote> 6月7日,9:56 pm,slinky< campbellbrian2 ... @ yahoo.comwrote:


尝试在我的浏览器中查看它,我收到服务器错误:



:-)


你得到什么错误?br />


Thanks in advance fo rany help... I have an XML data file (well-
formed) that I need to place into my website''s app_data folder. I
would like to have an .aspx form on my site that simply has two
textboxes (corresponding to two XML fields in my file), and a
"submit"
button that will update the file. Any clues as to the code to use?

I''m most familiar with the DataAdapter/DataSet model and using
SQLserver files and having an INSERT INTO query to update. Can this
be
used on an XML file also? There may be better ways, but just curious
if this model COULD work with XML.
Thanks!

解决方案

On Jun 5, 9:31 pm, slinky <campbellbrian2...@yahoo.comwrote:

Thanks in advance fo rany help... I have an XML data file (well-
formed) that I need to place into my website''s app_data folder. I
would like to have an .aspx form on my site that simply has two
textboxes (corresponding to two XML fields in my file), and a
"submit"
button that will update the file. Any clues as to the code to use?

I''m most familiar with the DataAdapter/DataSet model and using
SQLserver files and having an INSERT INTO query to update. Can this
be
used on an XML file also? There may be better ways, but just curious
if this model COULD work with XML.
Thanks!

Dim myDataSet as New DataSet()
myDataSet.ReadXml(Server.MapPath("books.xml"))

http://aspnet.4guysfromrolla.com/articles/052902-1.aspx

http://www.google.com/search?hl=en&q...et+xml+asp.net


Thanks! http://aspnet.4guysfromrolla.com/articles/052902-1.aspx is a
great site...but I tried out some of you code below from the site (I''m
a student-newbie using Visual Web Developer Express 2005). I pasted
the following into a blank .aspx page and your books.xml file into my
app_data folder on my site, re-build, and get rid of some errors, I
try to view it in my browser and I get server errors:

here''s my aspx:

<%@ import Namespace="System.Data" %>
<script runat="server">
sub Page_Load(sender as Object, e as EventArgs)
Dim myDataSet as New DataSet()

myDataSet.ReadXml(Server.MapPath("books.xml"))

dgBooks.DataSource = myDataSet
dgBooks.DataBind()

dgBooksPretty.DataSource = myDataSet
dgBooksPretty.DataBind()
end sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>StartPage</title>
</head>
<body>
<b>The Contents of the XML File
<a href="/demos/books.xml"><code>books.xml</code></a></b><br />
<asp:datagrid id="dgBooks" runat="server" />

<p align="center">
<b>A Nicer Looking DataGrid Representation of the XML File
<a href="/demos/books.xml"><code>books.xml</code></a></b><br />
</p>
<asp:datagrid id="dgBooksPretty" runat="server"
AutoGenerateColumns="False"
Font-Name="Verdana"
Font-Size="Small"
HorizontalAlign="Center"
ItemStyle-BackColor="#FFFFCC"
AlternatingItemStyle-BackColor="#EEEEEE">

<HeaderStyle BackColor="Red" HorizontalAlign="Center"
ForeColor="White" Font-Bold="True" />

<Columns>
<asp:BoundColumn HeaderText="Title" DataField="title" />
<asp:BoundColumn HeaderText="Author" DataField="author" />
<asp:BoundColumn HeaderText="Year" DataField="year" />
</Columns>
</asp:datagrid>

</body>
</html>

and here''s my xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<books>
- <book>
<title>Teach Yourself Active Server Pages 3.0 in 21 Days</title>
<author>Mitchell</author>
<year>1999</year>
</book>
- <book>
<title>Designing Active Server Pages</title>
<author>Mitchell</author>
<year>2000</year>
</book>
- <book>
<title>ASP.NET: Tips, Tutorials, and Code</title>
<author>Mitchell</author>
<year>2001</year>
</book>
- <book>
<title>ASP Unleashed</title>
<author>Walther</author>
<year>1998</year>
</book>
- <book>
<title>ASP.NET Unleashed</title>
<author>Walther</author>
<year>2002</year>
</book>
- <book>
<title>Creating Data Driven ASP.NET Applications</title>
<author>Seven</author>
<year>2002</year>
</book>
</books>

>
Dim myDataSet as New DataSet()
myDataSet.ReadXml(Server.MapPath("books.xml"))

http://aspnet.4guysfromrolla.com/articles/052902-1.aspx

http://www.google.com/search?hl=en&q...et+xml+asp.net



On Jun 7, 9:56 pm, slinky <campbellbrian2...@yahoo.comwrote:

try to view it in my browser and I get server errors:

:-)

What errors do you get?


这篇关于使用aspx和XML文件进行更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆