Imports System.Data
Imports System.Data.SqlClient

Public Class List
    Inherits System.Web.UI.Page

#Region " Web Form µðÀÚÀÌ³Ê¿¡¼­ »ý¼ºÇÑ ÄÚµå "

    'ÀÌ È£ÃâÀº Web Form µðÀÚÀÌ³Ê¿¡ ÇÊ¿äÇÕ´Ï´Ù.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub
    Protected WithEvents DataGrid1 As System.Web.UI.WebControls.DataGrid

    'Âü°í: ´ÙÀ½ÀÇ ÀÚ¸® Ç¥½ÃÀÚ ¼±¾ðÀº Web Form µðÀÚÀÌ³ÊÀÇ ÇÊ¼ö ¼±¾ðÀÔ´Ï´Ù.
    '»èÁ¦ÇÏ°Å³ª ¿Å±âÁö ¸¶½Ê½Ã¿À.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: ÀÌ ¸Þ¼­µå È£ÃâÀº Web Form µðÀÚÀÌ³Ê¿¡ ÇÊ¿äÇÕ´Ï´Ù.
        'ÄÚµå ÆíÁý±â¸¦ »ç¿ëÇÏ¿© ¼öÁ¤ÇÏÁö ¸¶½Ê½Ã¿À.
        InitializeComponent()
    End Sub

#End Region

    Dim intPage As Integer = 0
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If Not IsPostBack Then
            DataGrid1.PageSize = 5
            Listing()
        End If
    End Sub

    Private Sub Listing()
        Dim objCon As SqlConnection
        Dim objCmd As SqlCommand

        objCon = New SqlConnection("server=localhost;user id=dotnetnote;password=dotnetnote;database=dotnetnote")
        objCon.Open()

        objCmd = New SqlCommand("Select Num, Title, Name, PostDate, ReadCount From DotnetNoteBasicVB" & _
                        " Order By Num Desc", objCon)

        Dim objDa As SqlDataAdapter = New SqlDataAdapter
        objDa.SelectCommand = objCmd

        Dim objDs As DataSet = New DataSet
        objDa.Fill(objDs, "DotnetNoteBasicVB")

        DataGrid1.DataSource = objDs.Tables("DotnetNoteBasicVB").DefaultView
        DataGrid1.DataBind()
    End Sub

    Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles DataGrid1.PageIndexChanged
        DataGrid1.CurrentPageIndex = e.NewPageIndex
        Listing()
    End Sub
End Class
