Solved

Databind on Paging

Posted on 2010-11-09
5
214 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 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