Katolog isimli Xml dosyasındaki bilgileri Repeater nesnesinde göstereceğiz.
< HeaderTemplate >< / <>> de Repeater daki sütunların başlıklarını tanımlayacağız.
< ItemTemplate >< / <>> ve < <> > < / <>> de Xml dosyasında bağlanacağımız alanları tanımlayacağız.
< FooterTemplate > < / <>> kısmında da alt başlık tanımlayacağız.
Default.aspx.vb
Imports System.Data
Partial Class _Default
Inherits System.Web.UI.Page
Protected KayitSayisi As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim ds As DataSet = New DataSet
ds.ReadXml(MapPath("App_Data/katalog.xml"))
Repeater1.DataSource = ds
Repeater1.DataBind()
KayitSayisi = ds.Tables(0).Rows.Count
End If
End Sub
End Class
Default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
< ! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns="http://www.w3.org/1999/xhtml" >
< head runat="server" >
< title > < / title >
< / head >
< body >
< form id="form1" runat="server" >
< div >
< asp:Repeater ID="Repeater1" runat="server" >
< HeaderTemplate >
< table border="1" width="100%" >
< tr bgcolor="#000066" >
< th >< font color="#FFFFFF" >Şarkı< / font >< / th >
< th >< font color="#FFFFFF" >Artist< / font >< / th >
< th >< font color="#FFFFFF" >Ülke< / font >< / th >
< th >< font color="#FFFFFF" >Kampanya< / font >< / th >
< th >< font color="#FFFFFF" >Fiyat< / font >< / th >
< th >< font color="#FFFFFF" >Yıl< / font >< / th >
< / tr >
< / HeaderTemplate >
< ItemTemplate >
< tr bgcolor="#DDFFD7">
< td >< %#Container.DataItem("title")% >< / td >
< td >< %#Container.DataItem("artist")% >< / td >
< td >< %#Container.DataItem("country")% >< / td >
< td >< %#Container.DataItem("company")% >< / td >
< td >< %#Container.DataItem("price")% >< / td >
< td >< %#Container.DataItem("year")% >< / td >
< / tr >
< / ItemTemplate >
< AlternatingItemTemplate >
< tr bgcolor="#E8F5FF">
< td >< font color="black"><%#Container.DataItem("title")%></font></td>
< td >< %#Container.DataItem("artist")% >< / td >
< td >< %#Container.DataItem("country")% >< / td >
< td >< %#Container.DataItem("company")% >< / td >
< td >< %#Container.DataItem("price")% >< / td >
< td >< %#Container.DataItem("year")% >< / td >
< / tr >
< / AlternatingItemTemplate >
< FooterTemplate >
< tr bgcolor="#990000" >
< td colspan="6" >
< font face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF" size="2" >
< b > Kayıt Sayısı: < %= KayitSayisi % > < / b >
< / font >
< / td >
< tr >
< / table >
< / FooterTemplate >
< / asp:Repeater >
< / div >
< / form >
< / body >
< / html >
Böylece Xml dosyasındaki kayıtları kolayca Repeater nesnemize çekmiş olduk.
0 comments:
Yorum Gönder