asp:datagrid Paging

Geçenlerde bir iş için lazım olmuştu. Sizinle de paylaşmak istedim. Kolay gelsin.

Html Kısmı

<form id=”Form1″ runat=”server”>

<asp:DataGrid ID=”dgrdAccounts” runat=”server”
AllowPaging=”True” PageSize=”5″

Kod kısmı

Imports System.Data.SqlClient

Dim myConnection As SqlConnection = New SqlConnection(“Data Source=SYS1;Integrated             Security=SSPI;Initial Catalog=FinAccounting”)
Const strSQL As String = “SELECT AccountCode,Accountname,AccountDescription FROM             AccountsTable”
Dim myDataAdapter As SqlDataAdapter = New SqlDataAdapter(strSQL, myConnection)
Dim dstaccounts As New DataSet()

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack() Then
End If
End Sub

Sub BindDataGrid()
myDataAdapter.Fill(dstaccounts, “AccountsTable”)
dgrdAccounts.DataSource = dstaccounts
End Sub

Sub drdaccounts_pageIndexChanged(ByVal s As Object, ByVal e As DataGridPageChangedEventArgs)
dgrdAccounts.CurrentPageIndex = e.NewPageIndex
End Sub


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: