⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemdatabound.aspx

📁 asp.net技术内幕的书配源码
💻 ASPX
字号:
<%@ Import Namespace="System.Data.SqlClient" %>

<Script Runat="Server">

Sub Page_Load
  Dim conPubs As SqlConnection
  Dim cmdSelect As SqlCommand
  Dim dtrAuthors As SqlDataReader

  ' Retrieve records from database
  conPubs = New SqlConnection( "Server=localhost;UID=sa;PWD=secret;Database=Pubs" )
  cmdSelect = New SqlCommand( "Select * From Authors", conPubs )
  conPubs.Open()
  dtrAuthors = cmdSelect.ExecuteReader()

  ' Bind to Repeater
  rptAuthors.DataSource = dtrAuthors
  rptAuthors.DataBind()

  dtrAuthors.Close()
  conPubs.Close()
End Sub

Sub Repeater_ItemDataBound(s As Object, e As RepeaterItemEventArgs) 
  If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
    Dim lblAuthor As Label = e.Item.FindControl( "lblAuthor" )
    lblAuthor.Text = e.Item.DataItem( "au_lname" )
  End If 
End Sub

</Script>

<html>
<head><title>Repeater.aspx</title></head>
<body>
<form Runat="Server">

<asp:Repeater
  ID="rptAuthors"
  OnItemDataBound="Repeater_ItemDataBound"
  Runat="Server">

  <ItemTemplate>
  <asp:Label id="lblAuthor" Runat="Server"/>
  </ItemTemplate>

</asp:Repeater>

</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -