Solved

Databind on Paging

Posted on 2010-11-09
5
211 Views
Last Modified: 2012-05-10
Protected Sub BindGrid()
        gvProd.DataSource = dtSource
        gvProd.DataBind()
    End Sub

   
I have a gridview that is databound to a datatable. I have set the allowpaging property to true .
I have pasted the code I have for paging below. however when I click on the Page 2 button, there is no records displayed becasue the datatable's value is nothing. I am wondering if I need to get the datatable from viewstate afer the user clicks on Page 2? Please suggest. thanks

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

        gvProd.PageIndex = e.NewPageIndex
        BindGrid()



    End Sub
0
Comment
Question by:TrialUser
5 Comments
 
LVL 13

Accepted Solution

by:
devlab2012 earned 500 total points
ID: 34094388
you have to populate your datasource (dtSource) again. I think it does not have any data when the page is posted back
0
 
LVL 5

Expert Comment

by:roxviper
ID: 34094484
0
 

Author Comment

by:TrialUser
ID: 34095731
yeah, but my question is how do I set the sqldatasource' datasource. I pull data into a datatable from a stored procedure.
0
 
LVL 14

Expert Comment

by:raja_ind82
ID: 34099931
0
 

Author Closing Comment

by:TrialUser
ID: 34114438
thx
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now