Home
Forums
New posts
Search forums
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
C# Community
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Home
Forums
VB.NET
VB.NET General Discussion
Help With Paging?!
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Tmuldoon" data-source="post: 6915" data-attributes="member: 2656"><p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodePagingInDataGridWebControlVisualBasic.asp">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodePagingInDataGridWebControlVisualBasic.asp</a></p><p></p><p>I still have some issues. I used the MSDN code and it sort of works.</p><p>Now the paging works, but when I hit the number - it does not show my</p><p>records until I hit the search button again. I thought it would go to</p><p>the next records automatically. Not sure why? Do I need to do some</p><p>sort of refresh at the button level? </p><p></p><p>WHY DOESN'T IT PAGE AUTOMATICALLY!???</p><p></p><p>[Plus I also do not understand this line:</p><p></p><p>dsQuery = CType(Session("dataset"), DataSet1). I already have a</p><p>dataset defined at design time - what does this do? ]</p><p></p><p>Here is my code:</p><p>- my dataset is called 'ds'</p><p></p><p>Private Sub Page_Load(ByVal sender As System.Object, ByVal e As</p><p>System.EventArgs) Handles MyBase.Load</p><p> 'Put user code to initialize the page here</p><p></p><p> With dg</p><p> .AllowPaging = True</p><p> .PagerStyle.Mode = PagerMode.NumericPages</p><p> .PageSize = 5</p><p> .PagerStyle.PageButtonCount = 5</p><p> End With</p><p> If IsPostBack Then</p><p> ds = CType(Session("dataset"), DataSet1)</p><p> Else</p><p> daQuery.Fill(ds)</p><p> Session("dataset") = ds</p><p> DataBind()</p><p> End If</p><p> End Sub</p><p></p><p>The button code->filters out data with a dataview. So after the page</p><p>button is pressed - one gets a blank screen untill the button is</p><p>pressed again - then it moves to the next results.</p><p></p><p>Private Sub btn_Click(ByVal sender As System.Object, ByVal e As</p><p>System.EventArgs) Handles btn.Click</p><p> Dim Count As Integer</p><p></p><p> Dim dv As DataView = ds.Tables("DB").DefaultView</p><p> dv.RowFilter = "Title like '%" & txt.Text & "%' OR Address like</p><p>'%" & txt.Text & "%'"</p><p> Count = dv.Count</p><p> dg.DataSource = dv</p><p> dg.DataBind()</p><p> lblCount.Text = Count</p><p></p><p> End Sub</p><p></p><p>Paging:</p><p></p><p>- Hide quoted text -</p><p>- Show quoted text -</p><p>Private Sub dg_PageIndexChanged(ByVal source As Object, ByVal e As</p><p>System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles</p><p>dg.PageIndexChanged</p><p> dg.CurrentPageIndex = e.NewPageIndex</p><p> dg.DataBind()</p><p> End Sub</p></blockquote><p></p>
[QUOTE="Tmuldoon, post: 6915, member: 2656"] [url="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodePagingInDataGridWebControlVisualBasic.asp"]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vbcode/html/vbtskCodePagingInDataGridWebControlVisualBasic.asp[/url] I still have some issues. I used the MSDN code and it sort of works. Now the paging works, but when I hit the number - it does not show my records until I hit the search button again. I thought it would go to the next records automatically. Not sure why? Do I need to do some sort of refresh at the button level? WHY DOESN'T IT PAGE AUTOMATICALLY!??? [Plus I also do not understand this line: dsQuery = CType(Session("dataset"), DataSet1). I already have a dataset defined at design time - what does this do? ] Here is my code: - my dataset is called 'ds' Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Put user code to initialize the page here With dg .AllowPaging = True .PagerStyle.Mode = PagerMode.NumericPages .PageSize = 5 .PagerStyle.PageButtonCount = 5 End With If IsPostBack Then ds = CType(Session("dataset"), DataSet1) Else daQuery.Fill(ds) Session("dataset") = ds DataBind() End If End Sub The button code->filters out data with a dataview. So after the page button is pressed - one gets a blank screen untill the button is pressed again - then it moves to the next results. Private Sub btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn.Click Dim Count As Integer Dim dv As DataView = ds.Tables("DB").DefaultView dv.RowFilter = "Title like '%" & txt.Text & "%' OR Address like '%" & txt.Text & "%'" Count = dv.Count dg.DataSource = dv dg.DataBind() lblCount.Text = Count End Sub Paging: - Hide quoted text - - Show quoted text - Private Sub dg_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles dg.PageIndexChanged dg.CurrentPageIndex = e.NewPageIndex dg.DataBind() End Sub [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
VB.NET
VB.NET General Discussion
Help With Paging?!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top
Bottom