forked from cubika/OneCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefault.aspx.vb
More file actions
60 lines (51 loc) · 2.59 KB
/
Default.aspx.vb
File metadata and controls
60 lines (51 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'******************************** 模块头 **********************************\
' 模块名: Default.aspx.vb
' 项目名: VBASPNETShowSpinnerImage
' 版权(c) Microsoft Corporation
'
' 本页面是用于从XML文件中检索数据,并包含了PopupProgeress用户控件。
'
' This source is subject to the Microsoft Public License.
' See http://www.microsoft.com/en-us/openness/resources/licenses.aspx#MPL.
' All other rights reserved.
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'****************************************************************************
Imports System.Xml
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnRefresh_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnRefresh.Click
' 在这里我们使用Thread.sleep()代码暂停线程10秒模仿
' 一个昂贵、耗时的操作检索数据(如连接网络
' 数据库检索海量数据)
' 所以在实际的应用中,您可以删除此行。
System.Threading.Thread.Sleep(10000)
' 从XML文件中检索数据作为示例数据。
Dim xmlDocument As New XmlDocument()
xmlDocument.Load(AppDomain.CurrentDomain.BaseDirectory + "XMLFile/XMLData.xml")
Dim tabXML As New DataTable()
Dim columnName As New DataColumn("Name", Type.[GetType]("System.String"))
Dim columnAge As New DataColumn("Age", Type.[GetType]("System.Int32"))
Dim columnCountry As New DataColumn("Country", Type.[GetType]("System.String"))
Dim columnComment As New DataColumn("Comment", Type.[GetType]("System.String"))
tabXML.Columns.Add(columnName)
tabXML.Columns.Add(columnAge)
tabXML.Columns.Add(columnCountry)
tabXML.Columns.Add(columnComment)
Dim nodeList As XmlNodeList = xmlDocument.SelectNodes("Root/Person")
For Each node As XmlNode In nodeList
Dim row As DataRow = tabXML.NewRow()
row("Name") = node.SelectSingleNode("Name").InnerText
row("Age") = node.SelectSingleNode("Age").InnerText
row("Country") = node.SelectSingleNode("Country").InnerText
row("Comment") = node.SelectSingleNode("Comment").InnerText
tabXML.Rows.Add(row)
Next
gvwXMLData.DataSource = tabXML
gvwXMLData.DataBind()
End Sub
End Class