最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
某一目录下的所有 XML文件绑定到不同的DataGrid的方法
时间:2022-06-30 09:31:36 编辑:袖梨 来源:一聚教程网
<%@ Page Language="vb"%>
<%@ Import NameSpace = "System" %>
<%@ Import NameSpace = "System.Xml" %>
<%@ Import NameSpace = "System.IO" %>
<%@ Import NameSpace = "System.Collections" %>
<%@ Import NameSpace = "System.Web" %>
<%@ Import NameSpace = "System.Web.UI" %>
<%@ Import NameSpace = "System.Web.UI.WebControls" %>
<%@ Import NameSpace = "System.Data" %>
<%@ Import NameSpace = "System.Drawing" %>
Sub Page_Load( sender as object, e as System.EventArgs)
Dim dir As DirectoryInfo = New DirectoryInfo(Server.MapPath("remark"))
Dim files As FileInfo() = dir.GetFiles()
Dim count As Integer = files.Length
Dim i As Integer
dim j as Integer
dim k as Integer
For i = 0 To count - 1
If files(i).Name.SubString(files(i).Name.LastIndexOf(".")) = ".xml" Then
Dim ds As New DataSet()
ds.ReadXml(files(i).FullName)
for k=0 to ds.tables.count-1
Dim dt as DataGrid = New DataGrid()
dt.ID = "DataGrid" + i.ToString() + k.ToString()
dt.HeaderStyle.BackColor=Color.Red
dt.AutoGenerateColumns=false
Dim MyName as BoundColumn()
redim MyName(ds.tables(k).columns.count)
for j=0 to ds.tables(k).columns.count-1
MyName(j)=new BoundColumn()
MyName(j).HeaderText=ds.tables(k).columns(j).columnname
MyName(j).DataField=ds.tables(k).columns(j).columnname
dt.Columns.AddAt(0, MyName(j))
next
dt.DataSource = ds.Tables(k)
dt.DataBind()
Me.Controls.Add(dt)
next
End If
Next
End Sub
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20