Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

Databind on Paging

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
TrialUser
Asked:
TrialUser
1 Solution
 
devlab2012Commented:
you have to populate your datasource (dtSource) again. I think it does not have any data when the page is posted back
0
 
TrialUserAuthor Commented:
yeah, but my question is how do I set the sqldatasource' datasource. I pull data into a datatable from a stored procedure.
0
 
TrialUserAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now