Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Gridview Page Index Change
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01439612
Message ID:
01440856
Vues:
31
>UPDATE: I modified the GridView_PageIndexChanging method to be
>Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As
>        System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
>
>        Dim args As System.EventArgs = New System.EventArgs  ---> added
>        Button1_Click(Button1, args)  ---> added
>        GridView1.PageIndex = e.NewPageIndex
>        GridView1.DataBind()
>End Sub
>
>This seems to work but is it the proper way to get what I want?
>

ASP.NET does some magic behind the scenes view ViewState (code that is injected into the ASP.NET page when it's sent to the client). Among other things, it contains a representation of the data currently bound in the grid. If you right-click in the browser and select View Source you can see it - it's held in a hidden form variable named "__VIEWSTATE" and has the value store base64 encoded. It's used for (among other things) a simple way of being able to redisplay the exact same set of data between postbacks. But it only contains the currently visible data. When you do a postback for paging and try to change pages, you are changing to a page that you don't have data for, which is why it disappears. You have to requery/rebind the data source when you do that (which is why your call to Click() works - it's grabbing the data again for you).
-Paul

RCS Solutions, Inc.
Blog
Twitter
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform