0
votes

I have a list on the left side:

computers
mouses
keyboards
etc

I also have a gridview which appears when I press on one of them.

The problem is in paging: it doesn't appear

If I press on computers, it load a list on gridview and when i press on pag number two in gridview, gridview dissapears, and if i press on computers again i can see the list on page number two...

i want when i press on page 2, it load, i dont want my gridview dissapears...

properties..

AllowPaging=true
EnableSortingAndPaddingCallbacks=true
Sorting=true

do i forgeting something?

Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging

        GridView1.PageIndex = e.NewPageIndex

        Dim tabla As New DataTable()
        tabla = daoprod1.busquedaxCategorias(Session("micategoria"))
        GridView1.DataSource = tabla
        GridView1.DataBind()

    End Sub

i had tried of many forms and it continue dissapearing

2
You should show us the way you control the visibility of GridView2. It's also impottant not to DataBind the first GridView on Postbacks, hence check for not Page.IsPostBack. - Tim Schmelter

2 Answers

1
votes

Do you have a PageIndex changed event? If yes What is your code in PageIndex changed event?

Here is the MSDN link try the sample code provided.

0
votes

You don't need to create new datatable just add GridView1.PageIndex = e.NewPageIndex and your grid like this

Protected Sub GridView1_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles GridView1.PageIndexChanging

        GridView1.PageIndex = e.NewPageIndex
        Me.bindgrid()
    End Sub