Datagrid navigation problem

A

anand

Hello there,
Just a small problem while navigating datagrid, i am filling a datagrid by
output of query. i have given navigation buttons first,last, next,
previous.it is working but the problem is that i have to click twice to
navigate.any suggestion. i m using following code
Private Sub NavigationButtonClicked(ByVal sender As Object, _ByVal e As
EventArgs) Handles FirstPage.Click, PreviousPage.Click, NextPage.Click,
LastPage.Click Dim direction As String = CType(sender, Button).CommandName
Select Case direction.ToUpper() Case "FIRST"
DataGrid1.CurrentPageIndex = 0 Case "PREVIOUS"
DataGrid1.CurrentPageIndex = _ Math.Max(0,
DataGrid1.CurrentPageIndex - 1) Case "NEXT"
DataGrid1.CurrentPageIndex = _ Math.Min(DataGrid1.PageCount - 1,
_ DataGrid1.CurrentPageIndex + 1) Case "LAST"
DataGrid1.CurrentPageIndex = _ DataGrid1.PageCount - 1 Case
Else End Select DataGrid1.DataBind()End Sub
 
A

Ashish M Bhonkiya

Hi anand,

Check to see you are only binding the datagrid in the page_load if its not
postback

in Page_Load do databinding only if
if(!Page.IsPostBack)
{
DataGrid1.Datasource = yourdatasource;
DataGrid1.DataBind();
}


Regards
Ashish M Bhonkiya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top