惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
T
The Exploit Database - CXSecurity.com
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
Last Week in AI
Last Week in AI
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 聂微东
博客园 - Franky
美团技术团队
WordPress大学
WordPress大学
博客园 - 司徒正美
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
DataBreaches.Net
腾讯CDC
大猫的无限游戏
大猫的无限游戏
人人都是产品经理
人人都是产品经理
Microsoft Azure Blog
Microsoft Azure Blog
D
Docker
Security Archives - TechRepublic
Security Archives - TechRepublic
F
Fortinet All Blogs
T
Tor Project blog
G
GRAHAM CLULEY
Simon Willison's Weblog
Simon Willison's Weblog
I
InfoQ
Cyberwarzone
Cyberwarzone
V
V2EX
T
Tenable Blog
NISL@THU
NISL@THU
Scott Helme
Scott Helme
K
Kaspersky official blog
Latest news
Latest news
S
Schneier on Security
Martin Fowler
Martin Fowler
博客园 - 三生石上(FineUI控件)
Know Your Adversary
Know Your Adversary
Microsoft Security Blog
Microsoft Security Blog
S
Securelist
M
MIT News - Artificial intelligence
V
Vulnerabilities – Threatpost
P
Proofpoint News Feed
L
LangChain Blog
T
Threat Research - Cisco Blogs
Spread Privacy
Spread Privacy
T
Threatpost
有赞技术团队
有赞技术团队

博客园 - 飞鼠

面试时英语自我介绍范文 判斷一天是否是年月中正確的日 - 飞鼠 - 博客园 Javascript中parseInt的一個問題 NUMERIC(3,1) 的含義 在 google 里找书下载的捷径 - 飞鼠 使用asp.net发送邮件详解 創建用戶控件 - 飞鼠 - 博客园 SQL密码 不斷提醒 datagrid用xml作为数据源,并且有更新,删除和排序的操作(VB) - 飞鼠 - 博客园 将xml作为DataGrid 操作(Sort, Edit, Delete) - 飞鼠 用ASP.NET结合XML制作广告管理程序 用ASP.NET结合XML制作广告管理程序(2) - 飞鼠 - 博客园 XML、DataSet、DataGrid结合写成广告管理程序(下)(转载) - 飞鼠 - 博客园 XML、DataSet、DataGrid结合写成广告管理程序(上)(转载) 将某一目录下的所有相同格式的 XML文件绑定到不同的DataGrid - 飞鼠 - 博客园 创建可编辑的xml文档(之五)执行中的treeview 控件 创建可编辑的xml文档(之四) 删除、改名、插入操作 创建可编辑的xml文档(之三)执行拖放操作
分别用DataGrid、Repeater、DataList绑定XML数据的例子 - 飞鼠 - 博客园
飞鼠 · 2005-12-29 · via 博客园 - 飞鼠

data.aspx

<%@ Import Namespace="System" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>

<script language="VB" runat=server>
Dim ds As DataSet = new DataSet()
   Sub Page_Load(sender As Object, e As EventArgs)
      Dim fs     As FileStream
      Dim reader As StreamReader
      Dim Path   As String
      Path = Server.MapPath( "books.xml" )
      fs = New FileStream(Path, FileMode.Open, FileAccess.Read)
      reader = New StreamReader(fs, Encoding.Default)
      ds.ReadXml(reader)
      Grid1.DataSource = ds.Tables("book").DefaultView
      Grid1.DataBind()
      Repeater1.DataSource = ds.Tables("book").DefaultView
      Repeater1.DataBind()
      DataList1.DataSource = ds.Tables("book").DefaultView
      DataList1.DataBind()
   End Sub

   Sub ChangePage(sender As Object, e As DataGridPageChangedEventArgs)
      Grid1.DataSource = ds.Tables("book").DefaultView
      Grid1.DataBind()
      Repeater1.DataSource = ds.Tables("book").DefaultView
      Repeater1.DataBind()
      DataList1.DataSource = ds.Tables("book").DefaultView
      DataList1.DataBind()
   End Sub

   Sub DataList_ItemCommand(sender As Object, e As DataListCommandEventArgs)
     select case e.CommandSource.Text
    case "详细"
        DataList1.SelectedIndex = e.Item.ItemIndex
     case "关闭"  
        DataList1.SelectedIndex = -1
     end select
     DataList1.DataSource = ds.Tables("book").DefaultView
     DataList1.DataBind()
   End Sub

</script>
<html>
<head>
</head>
<body style="background-color:f6e4c6">
<Form runat="server">
<p>DataGrid演示</p>
<asp:DataGrid
    AllowPaging="True"
    PageSize="10"
    OnPageIndexChanged="ChangePage"
    PagerStyle-HorizontalAlign="Right"
    PagerStyle-NextPageText="下一頁"
    PagerStyle-PrevPageText="上一頁"
    HeaderStyle-BackColor="#AAAADD"
    AlternatingItemStyle-BackColor="#FFFFC0"
    BorderColor="Black"
    CellPadding="2"
    CellSpacing="0"
    id="Grid1" runat="server"/>

<p>Repeater演示</p>
<table border="1">
<asp:Repeater id="Repeater1" runat="server">

<template name="HeaderTemplate" >
<tr align="center"><th >书名</th><th>作者</th><th>价格</th></tr>
</template>

<template name="ItemTemplate">
<tr><td><%# Container.DataItem("title") %></td>
        <td><%# Container.DataItem("last-name") %>  <%# Container.DataItem("first-name") %></td>
        <td><%# Container.DataItem("price") %></td>
</tr>
</template>

</asp:Repeater>
</table>

<p>DataList 演示</p>
<asp:DataList id="DataList1" runat="server"
     Border="1" BorderColor="Black"
     CellPadding="2" CellSpacing="0"
     HeaderStyle-BackColor="#888888"
     ItemStyle-BackColor="#eeeeee"
     SelectedItemStyle-BackColor="#ffffff"
     HeaderTemplate-ColSpan="3"
     OnItemCommand="DataList_ItemCommand" >

<template name="HeaderTemplate" >

</template>

<!--内容模版-->
<template name="ItemTemplate">
书名:<%# Container.DataItem("title") %>
<asp:LinkButton id="detail" runat="server" Text="详细" ForeColor="#333333"/>
</template>

<template name="SelectedItemTemplate">
书名:<%# Container.DataItem("title") %><br>
作者:<%# Container.DataItem("last-name") %>  <%# Container.DataItem("first-name") %><br>
价格:<%# Container.DataItem("price") %><br>
<div align="right"><asp:LinkButton id="Title" runat="server" Text="关闭" ForeColor="#333333"/></div>
</template>

</asp:DataList>

</Form>
</body>
</html>

books.xml
<?xml version="1.0" encoding="gb2312"?>
<NewDataSet>
  <xsd:schema id="NewDataSet" targetNamespace="" xmlns="" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    <xsd:element name="book">
      <xsd:complexType content="elementOnly">
        <xsd:all>
          <xsd:element name="title" minOccurs="0" type="xsd:string"/>
          <xsd:element name="first-name" minOccurs="0" type="xsd:string"/>
          <xsd:element name="last-name" minOccurs="0" type="xsd:string"/>
          <xsd:element name="price" minOccurs="0" type="xsd:float"/>
        </xsd:all>
      </xsd:complexType>
    </xsd:element>
    <xsd:element name="NewDataSet" msdata:IsDataSet="True">
      <xsd:complexType>
        <xsd:choice maxOccurs="unbounded">
          <xsd:element ref="book"/>
        </xsd:choice>
      </xsd:complexType>
    </xsd:element>
  </xsd:schema>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">
    <title>The Confidence Man</title>
    <author>
      <first-name>Herman</first-name>
      <last-name>Melville</last-name>
    </author>
    <price>11.99</price>
  </book>
  <book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">
    <title>The Gorgias</title>
    <author>
      <name>Plato</name>
    </author>
    <price>9.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
  <book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">
    <title>The Autobiography of Benjamin Franklin</title>
    <author>
      <first-name>Benjamin</first-name>
      <last-name>Franklin</last-name>
    </author>
    <price>8.99</price>
  </book>
</bookstore>

</NewDataSet>