I'm having trouble with my pagination using grid view if the datasource is in Page_Load event.
But when I manually use the GridView -> choose datasource in its property, I don't have any problem with the pagination.
I'm using the Page_Load event because there are some parameters.
Please help and thanks in advance. I'm newbie in ASP.net. I've also attached the code I'm using.
Dim mycon As New SqlConnection("Data Source=xxx.168.14.xxx;Initial Catalog=mydatabase;User ID=myuser;Password=mypassword")
Dim myDataTable As New DataTable
Dim kcmd As New SqlClient.SqlCommand
Dim query As String
query = "select * from myquery "
mycon.Open()
kcmd.Connection = mycon
kcmd.CommandTimeout = 0
kcmd.CommandText = query
Dim kda As New SqlClient.SqlDataAdapter(kcmd)
Dim kdt As New DataTable
kda.Fill(kdt)
GridView1.DataSource = kdt