Solved

Databind on Paging

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

914 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

21 Experts available now in Live!

Get 1:1 Help Now