مثال آموزش اتصال کنترل Repeater به یک فایل XML در ASP.Net


کد <%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>


<script runat="server">
      sub Page_Load
        
if Not Page.IsPostBack then
           
  dim mycountries =New DataSet
             mycountries.ReadXml(MapPath("Countries_2.xml"))
             Countries.DataSource = mycountries
             Countries.DataBind()

         end if

      end sub

</script>
<html>
 <body>
   <form id="Form1" runat="server">
        <asp:Repeater id="Countries" runat="server">
           <HeaderTemplate>
                <table border="1" width="100%">
                   <tr>
                        <th>Title</th>
                        <th>Capital</th>
                        <th>Continent</th>
                  </tr>
          </HeaderTemplate>

          <ItemTemplate>
                <tr>
                    <td><%#Container.DataItem("title")%></td>
                    <td><%#Container.DataItem("Capital")%></td>
                    <td><%#Container.DataItem("Continent")%></td>
                </tr>
           </ItemTemplate>


           <FooterTemplate>
               </table>
           </FooterTemplate>

       </asp:Repeater>
   </form>

 </body>
</html>
خروجی
Title Capital Continent
Englang London Europe
USA Washington North America
France Paris Europe
Iran Tehran Asia