calvinkwoo3000 Newbie
Joined: 08 Feb 2006 Posts: 11
|
Posted: Mar 8th, 2006 01:23 AM Post subject: Paging problem in datagrid |
|
|
I have about 30 row data from database. I set the page size to 10.
It mean that i have 3 pages.
The datagrid have show me the number 1 , 2 , 3. after i click on the number 2 or 3
it stil shown me the 1st page.
And the bolded Public Sub below not function. Even i replace the binding to label1.text="something here".
May i know how to make the paging function?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Binding()
End Sub
Public Sub MyDG_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyDG.SelectedIndexChanged
Binding()
End Sub
Public Function Binding()
Dim selectSQL As String
Dim con As SqlConnection
Dim configuration As String
Dim check As Boolean
Dim cmd As SqlCommand
Dim dataAdapter As SqlDataAdapter
Dim dataSet As DataSet
Dim reader As SqlDataReader
' MyDG.Visible = True
con = New SqlConnection("SERVER=(local);DATABASE=calvinflash;UID=sa;PWD=sa;")
con.Open()
selectSQL = "SELECT * FROM newpost ORDER BY postid DESC "
cmd = New SqlCommand(selectSQL, con)
dataAdapter = New SqlDataAdapter(cmd)
dataSet = New DataSet
dataAdapter.Fill(dataSet, "newpost")
con.Close()
MyDG.DataSource = dataSet.Tables("newpost")
MyDG.DataBind()
con.Dispose()
End Function |
|