1 / 11

Paging datagridview VB.Net

Paging datagridview VB.Net. Pagination / paging. Pagination adalah proses pembagian data, menampilkan dan membatasi jumlah tampilan data Data yang diperlukan antara lain total data, posisi awal data defaultnya adalah record pertama dan data yng ditampilkan. Hasil Paging.

usoa
Download Presentation

Paging datagridview VB.Net

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Paging datagridviewVB.Net

  2. Pagination / paging • Pagination adalah proses pembagian data, menampilkandanmembatasijumlahtampilan data • Data yang diperlukanantara lain total data, posisiawal data defaultnyaadalah record pertamadan data yngditampilkan

  3. Hasil Paging

  4. Syntax • Pertamadan yang paling utama. tuliskan script berikutinipadabarispertama Imports System.Data.SqlClient

  5. DeklarasiVariabel • Selanjutnya, buatbeberapavariabel yang akandigunakan Dim da As SqlDataAdapter Dim startRecord As Integer = 0 'Deklarasi record dimulai Dim ds As DataSet Dim totalrecordperpage As Integer = 5 'Total record yang akanditampilkan per page

  6. Koneksi Database • Kemudian buat koneksi ke database MySql Private Function koneksi() As MySqlConnection Dim c As String = "server=localhost;userid=root;database=bidar" Dim cn As New MySqlConnection(c) Try cn.Open() Catch ex As Exception MsgBox(ex.Message) End Try Return cn End Function

  7. Menampilkan data Private Sub go() Try cek() da = New SqlDataAdapter("select * from tabel", koneksi) ds = New DataSetda.Fill(ds, startRecord, totalrecordperpage, "tabel") DataGridView1.DataSource = ds.Tables(0) Catch ex As Exception MsgBox(ex.Message) End Try End Sub

  8. GetRowaCount() • FungsiinibergunauntukMendapatkanjumlah record padadatabase Private Function GetRowsCount() As Integer da = New SqlDataAdapter("select * from coba", koneksi) ds = New DataSetda.Fill(ds) Return ds.Tables(0).Rows.Count End Function

  9. Cek • digunakanuntukmengaktifkandan non aktifkanbutton Private Sub cek() Dim endofrecord As Integer = GetRowsCount() / totalrecordperpage If startRecord = 0 Then btnprev.Enabled = False ElseIfstartRecord / totalrecordperpage = endofrecord Then btnNext.Enabled = False Else btnprev.Enabled = True btnNext.Enabled = True End If End Sub

  10. Cara penggunaan Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.ClickstartRecord = startRecord + totalrecordperpage go() End Sub Private Sub btnprev_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnprev.ClickstartRecord = startRecord - totalrecordperpage go() End Sub

  11. TERIMA KASIH Sumber : http://www.lab-informatika.com/Articles/105/Paging-datagridview-VB-Net

More Related