Gridview Not showing Data on page change, when pagechangeindex is alrady handaled

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kamalpsc
    New Member
    • Feb 2013
    • 1

    Gridview Not showing Data on page change, when pagechangeindex is alrady handaled

    hi,
    I have a gridview which is showing 10 record per page. I have manually set the Datasource. I have also set the gridView_PageIn dexChanging. when running it shows data in first page with all other page numbers. But, when click on 2nd or 3rd page no. it do not shows any data. I have 100 record in table. i want to show 10 records each page, how to solve this problem? please help me.

    Code:
       Function fillgvnhpclist()
    
            Dim qrystring As String
    
            qrystring = "select * from sahaj_driver_ order by emp_code,year_mon"
            objcommand = New OdbcCommand(qrystring, objconn)
            objda = New OdbcDataAdapter(objcommand)
            objda.Fill(objdt)
            If objdt.Rows.Count > 0 Then
                GVnhpc1.DataSource = objdt
                GVnhpc1.DataBind()
            End If
            Return 1
        End Function
    
       
        Protected Sub gridView_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GVnhpc1.PageIndexChanging
            GVnhpc1.PageIndex = e.NewPageIndex
            GVnhpc1.DataSource = objdt
            GVnhpc1.DataBind()
        End Sub
    
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            DatabaseConnection()
            Try
                objconn.Open()
               If (Page.IsPostBack) <> True Then
                    fillgvnhpclist()
                End If
            Catch ex As Exception
                If objconn.State = ConnectionState.Open Then
                    objconn.Close()
                End If
            End Try
        End Sub
    Last edited by Rabbit; Feb 27 '13, 04:46 PM. Reason: Please use code tags when posting code.
Working...