S
Sujith V. P.
Hi All,
I am facing a small problem of paging in DataGrid.I am binding the
dataset to the datagrid in page load as given below,
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.DataGrid1.AllowPaging = True
Me.DataGrid1.PagerStyle.Mode = PagerMode.NextPrev
Me.DataGrid1.PageSize = 10
Dim Cn As SqlConnection = New
SqlConnection("Server=sss;DataBase=sss;Uid=sa;PWD=sa")
Cn.Open()
Dim sqlAdapter As SqlDataAdapter = New SqlDataAdapter("Select TaskUniqueId
as TaskId,TaskDescription as Description,SubCategory from Tasks", Cn)
Dim dsTasks As New DataSet
sqlAdapter.Fill(dsTasks, "Tasks")
Me.DataGrid1.DataSource = dsTasks.Tables("Tasks")
Me.DataGrid1.DataBind()
Cn.Close()
End Sub
Then for paging am using the PageIndexChanges event of the datagrid as
below,
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
DataGrid1.PageIndexChanged
Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
End Sub
But when i click the next or previous button,the page is not navigated..but
during the second click its working fine..does anyone know this problem?
Waiting for a reply from anyone
Thanks in advance
Sujith V.P
I am facing a small problem of paging in DataGrid.I am binding the
dataset to the datagrid in page load as given below,
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.DataGrid1.AllowPaging = True
Me.DataGrid1.PagerStyle.Mode = PagerMode.NextPrev
Me.DataGrid1.PageSize = 10
Dim Cn As SqlConnection = New
SqlConnection("Server=sss;DataBase=sss;Uid=sa;PWD=sa")
Cn.Open()
Dim sqlAdapter As SqlDataAdapter = New SqlDataAdapter("Select TaskUniqueId
as TaskId,TaskDescription as Description,SubCategory from Tasks", Cn)
Dim dsTasks As New DataSet
sqlAdapter.Fill(dsTasks, "Tasks")
Me.DataGrid1.DataSource = dsTasks.Tables("Tasks")
Me.DataGrid1.DataBind()
Cn.Close()
End Sub
Then for paging am using the PageIndexChanges event of the datagrid as
below,
Private Sub DataGrid1_PageIndexChanged(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles
DataGrid1.PageIndexChanged
Me.DataGrid1.CurrentPageIndex = e.NewPageIndex
End Sub
But when i click the next or previous button,the page is not navigated..but
during the second click its working fine..does anyone know this problem?
Waiting for a reply from anyone
Thanks in advance
Sujith V.P