simpledatabound.vb

来自「asp.net技术内幕的书配源码」· VB 代码 · 共 40 行

VB
40
字号
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Collections

Namespace myControls

Public Class SimpleDataBound
Inherits Control

Private _dataSource As IEnumerable

Public Property DataSource As IEnumerable
Get
  Return _dataSource
End Get
Set
  _dataSource = Value
End Set
End Property

Protected Overrides Sub OnDataBinding( e As EventArgs )
  Dim DataEnum As IEnumerator
  Dim ltlLiteral As LiteralControl

  If Not DataSource Is Nothing
    Controls.Clear()
    DataEnum = DataSource.GetEnumerator()
    While ( DataEnum.MoveNext() )
      ltlLiteral = New LiteralControl( DataEnum.Current.ToString() )
      Controls.Add( ltlLiteral )
      Controls.Add( New LiteralControl( "<br>" ) )
    End While
  End If
End Sub

End Class

End Namespace

⌨️ 快捷键说明

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